Improve stdin support

Only read stdin if there were no files supplied and not in
tty mode or '-' supplied as first argument.

Fixes #563
Closes gh-567