# OutStream.WriteText([Text] [, Integer]) Method
> Version: _Available or changed with runtime version 1.0._
Writes text to an OutStream object.
## Syntax
```al
[Written := ]  OutStream.WriteText([Text: Text] [, Length: Integer])
```
## Parameters
OutStream
Type: outstream-data-type
An instance of the outstream-data-type data type.
*[Optional] Text*
Type: ../text/text-data-type
The text to write. If you do not specify this, a carriage return and a line feed are written.
*[Optional] Length*
Type: ../integer/integer-data-type
The number of characters to be written.
## Return Value
*[Optional] Written*
Type: ../integer/integer-data-type
If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
For more information about how zero bytes and line endings are written and read, see Write, WriteText, Read, and ReadText Method Behavior Regarding Line Endings and Zero Terminators<../../devenv-write-read-methods-line-break-behavior>.
## Example
This example also requires that the c:\\TestFiles folder exists.
```al
var
    MyHTMLFile: File;
    TestOutStream: OutStream;
begin
    MyHTMLFile.Create('c:\TestFiles\main.html');
    MyHTMLFile.CreateOutstream(TestOutStream);
    TestOutStream.WriteText('<html>');
    TestOutStream.WriteText;
    TestOutStream.WriteText('<head>');
    TestOutStream.WriteText('<title>My Page</title>');
    TestOutStream.WriteText('</head>');
    TestOutStream.WriteText;
    TestOutStream.WriteText('<P>Hello world!</p>');
    TestOutStream.WriteText;
    TestOutStream.WriteText('</html>');
    MyHTMLFile.Close;
end;
```
## Related information
outstream-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-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/methods-auto/outstream/outstream-writetext-method, 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/methods-auto/outstream/outstream-writetext-method/
