Pick fileno for prompt based on isatty
Fixed broken restoration of terminal settings. Fixes #68.
Only check if stdout/stderr are a tty once