Updated to support utf8 files with BOM at the beginning