Stops the loop when a y is found