TextInputStream and TextOutputStream

I want to read in a text file and then append data to the end of it.
Do I use TextInputStream to read it, close it, then use TextOutputStream to write it?

You may look at BinaryStream, if that will work for you. It has an open method that will allow opening in r/w mode. http://documentation.xojo.com/index.php/BinaryStream.Open

or if it is just “plain text” you can append to it without having to read the whole thing

SUB myLog(msg as string)
  Dim f As FolderItem
  Dim t As TextOutputStream
  f=<path to your text file>
  If Not f.exists Then
    t=TextOutputStream.Create(f)
  Else
    t=TextOutputStream.Append(f)
  End If
  t.write msg+EndOfLine
  t.close
END SUB

You don’t need the “if”, Append will create the file if it doesn’t exist. You can also use WriteLine instead of “msg+EndOfLine”.

WriteLine instead of Write
except is uses the wrong EndofLine character (or it used to at least)

You can set the TextOutputStream.Delimiter property.

Also, don’t forget that Create and Append will throw an exception is there’s an error and that you should have Exception handlers for an IOException surrounding your code.