# Замените 'input.txt' и 'output.txt' на ваши пути к файлам input_file = "data.txt" output_file = "data.txt" # Читаем в кодировке Windows-1251 with open(input_file, "r", encoding="cp1251") as f: text = f.read() # Универсальное удаление двойных переносов для Windows/Unix систем new_text = text.replace("\r\n\r\n", "\n").replace("\n\n", "\n") # Сохраняем (можно сохранить в современный utf-8 или оставить cp1251) with open(output_file, "w", encoding="cp1251") as f: f.write(new_text)