Remove calls of binmode to force html file output to be utf8 as there is some bad side effect. Thanks to akorotkov for the report.