Save file history when loading a file

Otherwise it isn't always saved, such as when terminating the program using Ctrl+C from the terminal.