The script command not only makes a record of what commands you run but also allows you to save the output generated so that you can examine it later or easily turn your command sequences into scripts ...
If you want to exit a loop before all the commands in the loop have been run and all of the loop values have been processed, this command is just what you need; it provides a way to exit a loop ...