Fixed problem when handling files with BOM