title: append contents from one file to another with newline separation
body: <p>I'm trying to, I think, replicate the <code>cat</code> functionality of the Linux shell in a platform-agnostic way such that I can take two text files and merge their contents in the following manner:</p>
  
  <p>file_1 contains:  </p>
  
  <pre><code>42 bottles of beer on the wall
  </code></pre>
  
  <p>file_2 contains:  </p>
  
  <pre><code>Beer is clearly the answer
  </code></pre>
  
  <p>Merged file should contain:  </p>
  
  <pre><code>42 bottles of beer on the wall  
  Beer is clearly the answer
  </code></pre>
  
  <p>Most of the techniques I've read about, however, end up producing:</p>
  
  <pre><code>42 bottles of beer on the wallBeer is clearly the answer
  </code></pre>
  
  <p>Another issue is that the actual files with which I'd like to work are incredibly large text files (FASTA formatted protein sequence files) such that I think most methods reading line-by-line are inefficient. Hence, I have been trying to figure out a solution using <code>shutil</code>, as below:</p>
  
  <pre><code>def concatenate_fasta(file1, file2, newfile):
      destination = open(newfile,'wb')
      shutil.copyfileobj(open(file1,'rb'), destination)
      destination.write('\n...\n')
      shutil.copyfileobj(open(file2,'rb'), destination)
      destination.close()
  </code></pre>
  
  <p>However, this produces the same problem as earlier except with "..." in between. Clearly, the newlines are being ignored but I'm at a loss with how to properly manage it.</p>
  
  <p>Any help would be most appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>I tried Martijn's suggestion, but the <code>line_sep</code> value returned is <code>None</code>, which throws an error when the function attempts to write that to the output file. I have gotten this working now via the <code>os.linesep</code> method mentioned as less-optimal as follows:</p>
  
  <pre><code>with open(newfile,'wb') as destination:
      with open(file_1,'rb') as source:
          shutil.copyfileobj(source, destination)
      destination.write(os.linesep*2)
      with open(file_2,'rb') as source:
          shutil.copyfileobj(source, destination)
      destination.close()
  </code></pre>
  
  <p>This gives me the functionality I need, but I'm still at a bit of a loss as to why the (seemingly more elegant) solution is failing.</p>