Added an exit command and an if statement to script loop to exit if read.