Corrected the loop conditions so that a newline will make it stop.