Add saving at the end of the script