'r', encoding='Shift_JIS') as f: for line in f: lines.append(line) with open('output.txt', 'w', encoding='UTF-8') as f: for line in lines: line = line.replace('.', '。') line = line.replace(',', '、') print(line, file=f) ファイルに書き込み with open(...) as f: を使うと 自動でf.close() replace:置換