Simulating old Haskell 1.2 stream based IO with IO monad