UnicodeDecodeError if stdin encoding is not utf-8

UnicodeDecodeError is raised if standard input encoding is not utf-8 (ie. on Windows).
This PR is using `sys.stdin.encoding` to decode input.
I have no objections in using `... if x else something`. Just saying that I'm used to form that I've used :)