in reply to fetchrow_array() issue

It would help if you close OUTFILE; at some point. If you don't, you could miss data that's still in the file buffer.