Code changed to exit whenever q is entered in a new line