Save history to file