in reply to increment record number

Why are you storing a computed value into the file? Can you not make your "reading" algorithm just compute the line number upon read? That would seem more efficient, and less likely to get out of sync later.

-- Randal L. Schwartz, Perl hacker