# -*- coding: utf-8 -*-
# wordcount3.py

fr = open("D:/HWP/강의자료/파이썬/codes/BTS_Dynamite_lyrics.txt", "r")
fw = open("D:/HWP/강의자료/파이썬/codes/BTS_Dynamite_lyrics.lis", "w")
counter = 0
fw.write("dynamite가 들어간 줄의 가사\n\n")
for line in fr:
    lcounter = line.lower().count("dynamite") 
    if lcounter > 0: 
        print(line)
        fw.writelines(line)
    counter = counter + lcounter
fr.close(); fw.close()
print (counter)