Fix readline input

For some reason flushing the input buffer confuses readline and it will
drop every other character.