Fixed bug with saving files