On macOS reading from the same tty device file as we are writing too in another thread gives continuous EAGAIN errors. We dont actually need simultaneous read/write, so move the reads to the end.