Check the JavaScript Tools Guide for details about the File object. Basically, it works more or less like this:
var oFile = new File ( /* full path name as text string */ );
oFile.open( "w" ); /* use "a" to append, "w" to remove existing text.
oFile.writeln ( "Whatever you want to write in there" );
oFile.close ( );
Ciao
Jang