fix file truncation issue.