in reply to Re: if (STDERR == STDOUT)
in thread if (STDERR == STDOUT)

Just to expand on ikegami's command line option suggestion (which I agree with), you may want to check out the command's tee or mkfifo. Either one of these 2 will be able to push text to more than one file (or pipe).