title: Create a summary text file of a folder with filename and the first two lines out of each file
body: <p>I have a directory with 260+ text files containing scoring information. I want to create a summary text file of all of these files containing filename and the first two lines of each file. My idea was to create two lists separately and 'zip' them. However, I can get the list of the filenames but I can't get the first two lines of the file into an a appended list. Here is my code so far:</p>
  
  <pre><code># creating a list of filename
  for f in os.listdir("../scores"):
      (pdb, extension) = os.path.splitext(f)
      name.append(pdb[1:5])
  
  # creating a list of the first two lines of each file
  for f in os.listdir("../scores"):
      for line in open(f):
          score.append(line)
          b = f.nextline()
          score.append(b)
  </code></pre>
  
  <p>I get an error the <code>str</code> had no attribute <code>nextline</code>. Please help, thanks in advance.</p>