trim the BOM only when the file is writable