Fix isatty()

Make sure output is flushed before it waits for input.