Needs to handle exceptions so that the while loop goes on forever