implemented the loop for reading input during the game