# -*- coding: utf-8 -*-
# wordcount3.py

fr = open("D:/htex/pythonbk/codesdata/대한민국헌법.txt", "r", encoding='utf-8')
fw = open("D:/htex/pythonbk/codesdata/대한민국헌법.lis", "w")
counter = 0
fw.write("\'대통령\'이 포함된 줄\n\n")
for line in fr:
    lcounter = line.count("대통령") 
    if lcounter > 0: 
        print(line)
        fw.writelines(line)
    counter = counter + lcounter
fr.close(); fw.close()
print (counter)