July 2018
Beginner
202 pages
5h 42m
English
The file handle returned by io.open has a lines member function. This function will return an iterator that can be used to retrieve every line of the file using a loop. The following code demonstrates how to read an entire file, one line at a time:
file = io.open("data.txt")lines = file:lines()print("Contents of file:");
for line in lines do print("\t" .. line)end