Added while loop to the reading method