f = open("647.txt", 'r')
f1 = open('Result647.txt', 'w')

#Change on1/25/18
word = "#CidrIp:"
linenum=0
for line in f.readlines():
    #print line
    if "IpProtocol" in line:
        continue
    elif "FromPort" in line:
        continue
    elif "ToPort" in line:
        continue
    elif "Comments" in line:
        continue
    elif "CidrIp:" in line:
        line2 = line.replace(word, "")
        f1.write(line2)
        #print(line2)
        linenum+=1
   # elif "# TODO: create ctmpl logic to make this listen on 80" in line:
   #     continue
   # elif "l1" in line:
   #     linenum+=1
   #     f1.write(line)
    #if "Address" in line:
    #    f1.write(line)
        #print (line)#
print(linenum)
#f1.write(linenum)

f1.close()
f.close()
