If its about thousands of entries you'd better consider putting your lines in a database
or create a second file as an index, holding the positions of the beginning of each line. in this case you should lookup and use the fseek() function quite a lot
but before you do that try to picture your files... its something like:
This is the first line.This is the second line.This is the third line....
Imagine all of the lines stuck in one! you will have to know where each line starts. The computer knows when the next line starts because it finds some characters with ascii values 13 or 10 ... same as \r \n