Fixed bug of saving files