in reply to Display sequential

You're reinitializing your counter before you process each section of a file (you really shouldn't use the same word (file) to describe two different things). Move the initialization of the counter before you start processing a file, and everything should be okay.

It's right there on line 32...

Did you try debugging this in any way, shape or form? print statements should have revealed the problem immediately.

BTW, if this is homework, you should go to your professor and ask for a tutor...