import os with open('README.md', 'r', encoding='utf-8-sig') as f: content = f.read() with open('README.md', 'w', encoding='utf-8', newline='\n') as f: f.write(content) print("README.md rewritten without BOM")