Changed input/output to use tty