Not only there is *a* way to do it, but there is more than one way to do it!
Seriously, here's what you should do:
A: read the file.
B: store only what you need based on the criteria you have been given
C: return what you stored
D: don't expect others to do your work.