b=[x for x in open('a.txt').readlines() if x.find('')>-1]with open('b.txt','w') as f: f.writelines(b)