in reply to Processing large files

As well as the above points, you don't seem to increment $counter at any point either, so it won't reach 3000...