In order to give you a definite answer, I would need to see
more of the code.
I suspect that you need to clear $-
($FORMAT_LINES_LEFT if in English mode) when
moving on to a new file. see perlvar and perlform in the core documentation
for more about this.