Added handling of input on stdin.