saving to file, proper handling of uncaught exceptions