Trying to fix bug in writing large files.