Explicit flush of stdout to preserve sys.stdout.encoding otherwise breaking output encoding.