Sollte man hier nicht besser WriteBuffer benutzen?
Zitat von
http://www.freepascal.org/docs-html/rtl/classes/tstream.write.html über TStream.Write:
This method should be used when the number of bytes that should be written is not determined. If a specific number of bytes should be written, use TSTream.WriteBuffer instead.