I am trying to write the data to a text file that I scraped using BeautifulSoup It prints the data in the console but not to the file
import requests
from bs4 import BeautifulSoup
base_url = 'https://www.aaabbbccc.com'
r = requests.get(base_url)
soup = BeautifulSoup(r.text)
outF = open("myOutFile.txt", "w", encoding='utf-8')
for story_heading in soup.find_all(class_="col-md-4"):
if story_heading.a:
print(story_heading.a.text.replace("\n", " ").strip())
outF.write(str(story_heading))
outF.write("\n")
else:
print(story_heading.contents[0].strip())
outF.close()