Hello,
If you are using the stream mode and PHP CLI, then you need to redirect the stream to an output, otherwise the content is displayed.
If you set the stream mode as true and then you open the script using a web browser, the DOCX is generated and downloaded. If you use PHP CLI you can redirect it, for example to a file:
$ php stream_mode_script.php > output.docx
or any other output. This is the way how streams work.
Regards.