Look up OpenFile/Writefile & CloseFile in the docs, along with all the commands under "File/Stream" in the 2D Category.
A short example:
f=WriteFile("test.dat")
WriteLine(f, "Line 1")
CloseFile(f)
It creates/overwrites a file called "test.dat" and puts one line into it: "Line 1".