Read from a file

Added by iNTERFACEWARE

How to open and read a file from disk, either one line at a time, or read the whole file at once

Source Code
   -- How to read a whole file
   
   -- get a file handle
   local f = io.open('test')
   -- read the whole file
   f:read('*a')
   -- close the file handle
   f:close()
   

   -- How to read one line from a file
   
   -- get a file handle
   local f = io.open('test')
   -- read one line from the file
   f:read('*l')
   -- read another line from the file
   -- default is to read a one line
   f:read()
   -- close the file handle
   f:close()
Description
How to open and read a file from disk, either one line at a time, or read the whole file at once