# Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators
When 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:
 Write adds a 0 byte at the end of the stream; WriteText does not.
 Read Reads until a 0 byte or the specified length of the string.
 ReadText Reads the until a zero byte, an end-of-line, the specified number of bytes, or the maximum length.
To help understand this, consider the following code example. This example assumes that a BLOB field called MyBlobField exists in a table called MyBlobTable.
```al
var
    myInt: Integer;
    MyRecord: Record MyBlobTable;
    MyOutStream: OutStream;
    MyInStream: InStream;
    Result: Text;
    CRLF: Text[2];
}
begin
    MyRecord.MyBlobField.CreateOutStream(MyOutStream);
    MyOutStream.WriteText('A');
    MyOutStream.WriteText;
    MyOutStream.WriteText('B');
    MyOutStream.WriteText;
    MyOutStream.WriteText('C');

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.ReadText(Result); // Reads A
    Message(Result);
    MyInStream.ReadText(Result); // Reads B
    Message(Result);
    MyInStream.ReadText(Result); // Reads C
    Message(Result);

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.Read(Result); // Reads A\B\C
    Message(Result);

    CRLF[1] := 13;
    CRLF[2] := 10;
    MyRecord.MyBlobField.CreateOutStream(MyOutStream);
    MyOutStream.Write('A' + CRLF + 'B');
    MyOutStream.Write('C');

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.ReadText(Result); // Reads A
    Message(Result);

    MyInStream.ReadText(Result); // Reads B
    Message(Result);

    MyInStream.ReadText(Result); // Reads C
    Message(Result);

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.Read(Result); // Reads A + CRLF + B
    Message(Result);

    MyInStream.Read(Result); // Reads C
    Message(Result);

    Clear(MyRecord.MyBlobField);
    MyRecord.MyBlobField.CreateOutStream(MyOutStream);
    MyOutStream.WriteText('A' + CRLF + 'B');
    MyOutStream.WriteText('C');

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.Read(Result); // Reads A + CRLF + BC
    Message(Result);

    MyRecord.MyBlobField.CreateInStream(MyInStream);
    MyInStream.ReadText(Result); // Reads A
    Message(Result);
    MyInStream.ReadText(Result); // Reads BC
    Message(Result);

end;

```
## Related information
Write and WriteText Methods<methods-auto/outstream/outstream-data-type>
Read and ReadText Methods<methods-auto/instream/instream-data-type>
AL Development Environment<devenv-reference-overview>

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. https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-write-read-methods-line-break-behavior/
