This method encodes and write the passed in string and advance the stream's position.
If the write fails, then the stream's position is unaffected and an error returned.
var fileStreamObj = shell.serviceManager.basics.fileStream;
var streamWriterObj = shell.serviceManager.basics.rawStreamWriter;
fileStreamObj.openForWrite("c:\\temp\\test2.txt", true, true);
streamWriterObj.stream = fileStreamObj;
//this will write the content currently in text.txt to the end of itself
streamWriterObj.writeString("Test writeStream and writeString", "");
fileStreamObj.close();