Работа с файлами / Текстовые файлы

file_name = "file.txt"
text = "Line 1\nLine 2"

File.write(file_name, text)