The anamoly occurs at exactly line 5000 is that consistently the case?
It might be your client playing tricks on you, can you reproduce the issuein psql?
Regards,
Feike