Access the standard streams consistently.
Check STDOUT for tty-ness instead of STDIN when it's for output.