Use a while loop to read file contents.