Automatically save file at the end