io.output

Opens a file for output

Prototype

f = io.output (filename)

Description

Opens filename for output in text mode. Raises an error if it cannot.

If opened OK returns a handle to the opened file, and makes it the default output file.

If called with no argument, returns the handle to the default output file.

If called with a file handle, sets the default output file to that handle.

f = io.output ("test.txt") --> handle to new file
f:write ("some data here") -- write to it
f:close ()  -- close that file now

Lua functions

Topics