Fred, your only and biggest problem is that in a Lazarus GUI app, stdin/out/err are not available by default on Windows.
That is all.
This is also true for Delphi.
The easiest way to get around it is specifying {$apptype console} and hide the console.
I have shown quite a few times how to do that. On almost all other platforms, there is always a working set of stdin/out/err by default.