title: Biopython SeqIO: how to write modified SeqRecord header
body: <p>I thought I'd try using Biopython to salvage some trivially corrupted fastq files provided by a collaborator. I simply need to modify header lines (starting with <code>@</code>) which contain a certain substring. However, the new fastq files created by the following code are unchanged. No doubt I'm missing something obvious.</p>
  
  <p>What is the correct way to write a modified fastq SeqRecord?</p>
  
  <pre><code>import os, sys
  from Bio import SeqIO
  
  path_to_reads = sys.argv[1]
  if not os.path.exists(path_to_reads + '/fixed'):
      os.mkdir(path_to_reads + '/fixed')
  
  fwd_fastqs = [fn for fn in os.listdir(path_to_reads) if fn.endswith('_F.fastq')]
  rev_fastqs = [fn for fn in os.listdir(path_to_reads) if fn.endswith('_R.fastq')]
  fastq_pairs = zip(fwd_fastqs, rev_fastqs)
  
  for fastq_pair in fastq_pairs:
      with open(path_to_reads + '/' +  fastq_pair[0], 'rU') as fwd_fastq:
          with open(path_to_reads + '/fixed/' +  fastq_pair[0], 'w') as fixed_fwd_fastq:
              fixed_fwd_records = []
              for fwd_record in SeqIO.parse(fwd_fastq, 'fastq'):
                  fwd_record.name = fwd_record.name.replace('/2','/1')
                  fixed_fwd_records.append(fwd_record)
              SeqIO.write(fixed_fwd_records, fixed_fwd_fastq, 'fastq')
      # ...
  </code></pre>
  
  <p>Input data (two records, header lines start with <code>@</code>):</p>
  
  <pre><code>@MISEQ01:115:000000000-A8FBM:1:1112:18038:15085/1
  GATCGGAAGAGCACACGTCTGAACTCCAGTCACTGCCAATCATCTCGTATGCCGTCTTCTGCTTG
  +
  AAAAAAAAAF4CGGGGGAGGGFGHBHGHC5AGEGFFHGA3F355FGG223FFAEE0GCGA55BAB
  @MISEQ01:115:000000000-A8FBM:1:1101:20590:9966/2
  GATCACTCCCCTGTGAGGAACTACTGTCTTCACGCAGAAAGCGTCTAGCCATGGCGTTAGTATGA
  +
  1&gt;A111DFBA1CFA1FFG1BFGB1D1DGFGH3GECA0ABFFG?E///DDGFBB0FEAEEFBDAB2
  </code></pre>