Problem solved :). Instead of closing the stream after the string is written, the writer has to be closed. Otherwise, the writer will only write the size of its buffer that apparently is 1024.
It works fine this way:
Stream = New IO.FileStream(FilePath, _
Writer = New IO.StreamWriter(Stream)