Made sure BOM is the first character

Instead of ignoring mid-string BOM characters, verify that it is the first character in the string.