Dr.Avocado,
I am not commenting on your existing implementation as others have already done so. There are typically 3 ways that you would accomplish this:
- Go through the file once printing any line matching any suite
- Go through the file once pushing each matching line into an appropriate buffer (4 in your case) and then processing each buffer
- Loop through the file as many times as you have things to match
While I think it is likely a bad idea, you seem to want to know how to do number 3. See seek.