fix a bug that would truncate large files