fixed bug where files containing null character got truncated