Added error handler for stdin and stdout.
Merge pull request #4 from freezy/errorfix

Added error handler for stdin and stdout.