Save history to file on every prompt