Found a bug in tty_write