{"title":"Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-write-read-methods-line-break-behavior/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-write-read-methods-line-break-behavior, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-write-read-methods-line-break-behavior","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators.","date":"2021-04-01","meta":{"topic":"article"},"outline":[{"level":1,"title":"Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators","slug":"write-writetext-read-and-readtext-method-behavior-for-line-endings-and-zero-terminators","at":0,"chars":2745},{"level":2,"title":"Related information","slug":"related-information","at":2529,"chars":216}],"text":"# Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators\nWhen writing to and reading from a stream object using the Write, WriteText, Read, and ReadText methods, it is important to be aware of the following behavior regarding line endings and zero byte terminators:\n Write adds a 0 byte at the end of the stream; WriteText does not.\n Read Reads until a 0 byte or the specified length of the string.\n ReadText Reads the until a zero byte, an end-of-line, the specified number of bytes, or the maximum length.\nTo help understand this, consider the following code example. This example assumes that a BLOB field called MyBlobField exists in a table called MyBlobTable.\n```al\nvar\n    myInt: Integer;\n    MyRecord: Record MyBlobTable;\n    MyOutStream: OutStream;\n    MyInStream: InStream;\n    Result: Text;\n    CRLF: Text[2];\n}\nbegin\n    MyRecord.MyBlobField.CreateOutStream(MyOutStream);\n    MyOutStream.WriteText('A');\n    MyOutStream.WriteText;\n    MyOutStream.WriteText('B');\n    MyOutStream.WriteText;\n    MyOutStream.WriteText('C');\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.ReadText(Result); // Reads A\n    Message(Result);\n    MyInStream.ReadText(Result); // Reads B\n    Message(Result);\n    MyInStream.ReadText(Result); // Reads C\n    Message(Result);\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.Read(Result); // Reads A\\B\\C\n    Message(Result);\n\n    CRLF[1] := 13;\n    CRLF[2] := 10;\n    MyRecord.MyBlobField.CreateOutStream(MyOutStream);\n    MyOutStream.Write('A' + CRLF + 'B');\n    MyOutStream.Write('C');\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.ReadText(Result); // Reads A\n    Message(Result);\n\n    MyInStream.ReadText(Result); // Reads B\n    Message(Result);\n\n    MyInStream.ReadText(Result); // Reads C\n    Message(Result);\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.Read(Result); // Reads A + CRLF + B\n    Message(Result);\n\n    MyInStream.Read(Result); // Reads C\n    Message(Result);\n\n    Clear(MyRecord.MyBlobField);\n    MyRecord.MyBlobField.CreateOutStream(MyOutStream);\n    MyOutStream.WriteText('A' + CRLF + 'B');\n    MyOutStream.WriteText('C');\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.Read(Result); // Reads A + CRLF + BC\n    Message(Result);\n\n    MyRecord.MyBlobField.CreateInStream(MyInStream);\n    MyInStream.ReadText(Result); // Reads A\n    Message(Result);\n    MyInStream.ReadText(Result); // Reads BC\n    Message(Result);\n\nend;\n\n```\n## Related information\nWrite and WriteText Methods<methods-auto/outstream/outstream-data-type>\nRead and ReadText Methods<methods-auto/instream/instream-data-type>\nAL Development Environment<devenv-reference-overview>"}