Fix the case when the app is not run on a tty

Meaning sys.stdin.encoding is None --> use default one