title: Script failing to open and append multiple files simultaneously
body: <p>So trying to finish a very simple script that has given me a unbelievably hard time.  It's supposed to iterate through specified directories and open all text files in them and append them all with the same specified string.</p>
  
  <p>The issue is it's not doing anything to the files at all.  Using print to test my logic I've replaced lines 10 and 11 with <code>print f</code> (the write and close functions), and get the following output:</p>
  
  <pre><code>&lt;open file '/Users/russellculver/documents/testfolder/.DS_Store', mode 'a+' at
  </code></pre>
  
  <p>So I <strong>think</strong> it is storing the correct files in the f variable for the write function, however I am not familiar with how Mac's handle DS_STORE or the exact role it plays in temporary location tracking.</p>
  
  <p>Here is the actual script:</p>
  
  <pre><code>import os
  
  x = raw_input("Enter the directory path here: ")
  
  def rootdir(x):
      for dirpaths, dirnames, files in os.walk(x):
          for filename in files:
              try:
                  with open(os.path.join(dirpaths, filename), 'a+') as f:
                      f.write('new string content')
                      f.close()
              except:
                  print "Directory empty or unable to open file."
              return x
  rootdir(x)
  </code></pre>
  
  <p>And the exact return in Terminal after execution:</p>
  
  <pre><code>Enter the directory path here: /Users/russellculver/documents/testfolder
  Exit status: 0
  logout
  
  [Process completed]
  </code></pre>
  
  <p>Yet nothing written to the .txt files in the provided directory.</p>