Well, you really need to read line by line to ensure that you are in line X, unless you have fixed line sizes.
Other thing that you can do, to avoid to alwasy read all the file, is to save something like an index of the position in bytes of some lines in an extra file. Soo, for a big file you can have some indexed lines, and when you want to go to line X, you choose the nearest indexed line to start to search for line X, but note that the search for the nearest line in the index need to be very fast and small, or you won't get too much optimization.
Graciliano M. P.
"Creativity is the expression of the liberty".