fix bugs when file contains utf8 data