Send debug messages to the right descriptor

This was creating problem when using the stdout of a function as the result
Fixes missing space in if condition