fix flushing stdin to not affect stdout

Fix issue introduced in #249.