Added error handler for stdin and stdout.