f:lines

Returns an iterator function for reading the file line-by-line

Prototype

it = f:lines ()

Description

Returns an iterator function that reads the open file line-by-line.

At end of file, returns nil.

It does not close the file.

f = io.input ("test.txt")
for line in f:lines () do
  print (line)
end 
f:close ()  -- close that file now

 --> Entire contents of file listed

Lua functions

Topics