Another possible alternative is to read the file into memory all at once and use it from there. This can be done with anyone of the standard dynamic containers: http://www.cplusplus.com/reference/stl/
I should note that this is impractical for very large files. Anything over I'd say a Gig may be better off with a different approach depending on the system that it is being run on.