Okay, first of all, that's C style file operation.
It's ok, just not want to confuse you.
If I were you, I would read things from file into some appropriate data structure (like array) in one pass. Then access the ones I want.
However, if the data is really a "one time business", don't bother storing all the stuff in the file. You could check the data pieces while you're reading them from file; discard useless stuff and store the wanted.
Make your own judgement on the situation.