Final answer:
The question asks for a program to display each line from a text file using a while loop. The example provided is in Python and utilizes the file.readline() method within the loop to read and print each line until the end of the file is reached.
Step-by-step explanation:
The student's question involves writing a short program using a while loop to display each line of a text file. Here is an example of a Python program that accomplishes this:
with open('data.txt', 'r') as file:
line = file.readline()
while line:
print(line, end='')
line = file.readline()
This program opens the file called data.txt, reads the first line, and then enters a while loop that will continue running as long as there is content in the variable line. Within the loop, the program prints the line without adding an extra newline (because print adds one by default), and then reads the next line from the file. When the end of file is reached, readline() returns an empty string, which is considered False in a boolean context, and the loop terminates.