Added try/catch when saving datafile to handle IOErrors.