Several meg files is nothing nowdays to read into memory at once
Ok so maybe you can, however, if you could do the same with just reading one line into the buffer surely this would be better?
Recall the OP said:-
Are you saying he should read all those lines into memory?There is 939197 lines in this file.
I'm just saying if you could make the code more efficient then surely that would be the optimal choice? Right?