Fixed bug when resaving file