In FreePascal a Console needs be assigned under Windows. I you do {$apptype console} then it works. (you don't have to show the console}.
On other platforms, like on linux, your code should always work.
The very weird issue is that on Windows, stdin/out/error are not available as default.
In trunk, there are many fixes, also for Mac, but that is out of the question for production code of course. The problem I described is Windows only.
Can you maybe describe the setup a bit better? The part you showed is/starts with nil, the real nil, so something that should be there isn't there....