fp = open("123.txt", "r",encoding='utf-8')
sample = fp.readlines()
file = open("text.txt", "w")
for line in sample:
line = line.strip()
if '2222' in line:
print(line)
file.write(line)
file.write('\n')
fp.close()
fp = open("123.txt", "r",encoding='utf-8')
sample = fp.readlines()
file = open("text.txt", "w")
for line in sample:
line = line.strip()
if '2222' in line:
print(line)
file.write(line)
file.write('\n')
fp.close()