Proper stdin flushing