Use can get all lines containing 'apple' using a list-comprehension:
[ line for line in open('textfile') if 'apple' in line]
So - also in one code-line - you can create the new textfile:
open('newfile','w').writelines([ line for line in open('textfile') if 'apple' in line])
And eyquem is right: it's definitely faster to keep it as an iterator and write
open('newfile','w').writelines(line for line in open('textfile') if 'apple' in line)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…