It appears that you might be thinking you need to "hand off" all the output from main and give it to your parser, like handing a completed file folder to someone else. If that is the case, rethink the application -- consider creating a parser tool that you can instantiate inside of main, and have it process the file's strings as you go (within that while loop).
Don't know if that helps, but what the heck.
jk