Use tty name of stdin

When stdout is piped or its stdout is redirected, the tty name detection will
return an error. The only way to preven the issue is to use the tty name of the
stdin since most likely, it will be connected to the tty which the user is
facing.