Improve handling of files with errors. Records with errors are listed, and the file can be saved without them. Attempt to ensure file is truncated before saving to prevent file corruption.