For loops are generally used when you know the exact amount of numbers you are dealing with. Otherwise if you don't and in this case, you're recommended to use while loops, since you don't know how long it's going to take for the loop to end.
You 'could' use a for loop with some tweaking but it just makes for confusing syntax.
To count the number of lines in the file you have to read all the lines.:) So there is no any sense in such an operation even if the first line contains some number that is considered as the total number of lines. In any case it is better to use the while loop because it is possible that some errors will occur during reading lines.