Fix some corruption issues in truncate-end.pl.