fix file losing into memory issue