title: Error writing over source HTML file after BeautifulSoup edit
body: <p>Here is my code:</p>
  
  <pre><code>#Manipulating HTML and saving changed with BeautifulSoup
  
  
  
  #Importing libraries
  from bs4 import BeautifulSoup
  
  #Opening the local HTML file
  site_html = open(r"C:\Users\rbaden\desktop\KPI_Site\index.html")
  
  
  #Creating Soup from source HTML file
  soup =BeautifulSoup(site_html)
  #print(soup.prettify())
  
  
  #Locate and view specified class in HTML file
  test = soup.find_all(class_='test-message-one')
  print(test)
  
  
  #Test place holder for a python variable that should replace the specified class
  var = ('Testing...456')
  
  
  #Replace the class in soup redition of HTML
  for i in soup.find_all(class_='test-message-one'):
      i.string = var
  
  
  #overwriting the source HTML file on local drive
  with open(r"C:\Users\rbaden\desktop\KPI_Site\index.html")
      f.write(soup.content)
  </code></pre>
  
  <p>This is the error:</p>
  
  <p><img src="https://i.stack.imgur.com/5RDtX.jpg" alt="enter image description here"></p>
  
  <p>How do I correctly overwrite the entire source file with a new file after the changes made with beautifulsoup?</p>