Easy Way to Write a File?

BlitzMax Forums/BlitzMax Programming/Easy Way to Write a File?

I tried the stream, but it just keeps replacing the file? Surely, I don't have to read the entire file and append just to do this?

Function WriteErrorToFile(sMessage:String)

	Try
		Local pTStream:TStream = Null

		'Open the Error Log.
		pTStream = OpenStream("Error.txt")
	
		If not pTStream 
			Throw ("Failed to Open the Error.txt File.") 
		End If

		While not Eof(pTStream)
			ReadLine(pTStream)
		Wend


		WriteLine pTStream, sMessage
		CloseStream pTStream
		
    Catch ex:Object   
		Print ex.ToString() 
		End
	End Try   
	
End Function