Fixed a serious bug in saving files.