Fix STDIN input reading and redirection.

Use IO.pipe to redirect original STDIN content.