Modified to detect if stdin is tty - provides better syntax