Having Trouble outputting to a file
<p>I have this simple code here </p>

<pre><code>import os

path = (raw_input("Enter dir: "))   
f = open('script_list.log', 'w')
for dirpath, dirname, filenames in os.walk(path):
  for filename in [f for f in filenames]:
    f.write(str(filename) + "\n")
    print os.path.join(dirpath, filename)
</code></pre>

<p>When I run it I am getting the following </p>

<pre><code>Enter dir: scripts
Traceback (most recent call last):
  File "C:\Documents and Settings\CRichards\My Documents\My Dropbox\this_code.py", line 8, in &lt;module&gt;
    f.write(str(filename) + "\n")
AttributeError: 'str' object has no attribute 'write'
</code></pre>

<p>I know it must be something simple, I just can't see it.</p>
