This is what I would do, inside your function:
with open('input.txt','r') as inFile, open('output.txt','w') as outFile:
for line in inFile:
print(''.join([word for word in line.lower().translate(None, string.punctuation).split()
if len(word) >=4 and word not in stopwords.words('english')]), file=outFile)
Dont forget to add:
from __future__ import print_function
if you are on Python 2.x.