fix file truncation error