title: How can my input to a variable not be defined within python
body: <p>Im making a program that will ask the user for their first name and surname. 
  This data is then saved to a .txt file. 
  I understand that the coding is basic and easy to understand but just recently this code has decided to not work.</p>
  
  <pre><code>file1 = open("document.txt",'w')
  
  firstname = input("What is your first name?")
  
  secondname = input("what is you second name?")
  file1 = open ('document.txt','w')
  file1.write (firstname + secondname)
  
  newfile.close()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1HvXp.png" rel="nofollow noreferrer">I am given the following error when running this piece of code</a></p>