title: Functions handling save as and save buttons are not working
body: <p>I am trying to build a notepad but I am having problem with my save and saveas buttons as the contents in the TextField don't save, the text document is always returning empty, here is my code:</p>
  
  <pre><code>def saveFile():
      global infile
      global in_path
      global txt
      try:
          if in_path == '':
      #save as new file
              in_path = asksaveasfile(initialfile='Untitled.txt', defaultextension='txt',filetypes=[("All Files","*.*"),("Text Documents","*txt")])
              if in_path == "":
                  in_path = None
              else:
                  #try to save file
                  with open(in_path, "w") as infile:
                     data = (txt.get(1.0, END))
                     infile.write(data)
  
                      #change the window title
                  root.title(os.path.basename(in_path))
          else:
              #try to save file
              with open(in_path, "w") as infile:
                  infile.write(txt.get(1.0, END))
                  #change the window title
                  root.title(os.path.basename(in_path))
      except:
          pass        
  def saveAs():
      global infile
      global in_path
      global txt
      try:
      #save as new file
          in_path = asksaveasfile(initialfile='Untitled.txt', defaultextension='txt',filetypes=[("All Files","*.*"),("Text Documents","*txt")])
          if in_path == " ":
              in_path = None
          else:
                  #try to save file
              with open(in_path, "w") as infile:
                  infile.write(txt.get(1.0, END))
                  #change the window title
              root.title(os.path.basename(in_path))
      except:
              pass
  </code></pre>