title: NameError : name ' ' not defined
body: <p>So I'm merging two documents and outputting a third file </p>
  
  <p>I get the error </p>
  
  <pre><code>Traceback (most recent call last):
  File "summarize.py", line 124, in &lt;module&gt;
  train_data = set(document3)
  NameError: name 'document3' is not defined
  </code></pre>
  
  <p>This is what I have done:</p>
  
  <p>Code:</p>
  
  <pre><code>     filenames = ["/home/mustafa/data/combinedfile.txt", "/home/mustafa/data/sentences.txt"]
       with open("document3", "wb") as outfile:
           for fname in filenames:
               with open(fname) as infile:
                    outfile.write(infile.read())
       train_data = set(document3)
  </code></pre>
  
  <p>What am I doing wrong?</p>