save history to file