applied Jukka's stdinread patch