title: How to write String template file with multiple loop elements?
body: <p>I have small issue in writing for loop elements in string template as follows:  when I try to make a string templete from three loop elements I can able to print only the last element not the first two elements. I beleive that the error is because of some issues in writing file but I couldnt get what is the actual problem is with my code. So If some one could you kindly help me with this.</p>
  
  <pre><code>My SCRIPT:
  
  from string import Template
  import os
  
  AMONIOACIDS = {'A': 'ALA', 'C': 'CYS', 'E': 'GLU', 'D': 'ASP', 'G': 'GLY',
             'F': 'PHE', 'I': 'ILE', 'H': 'HIS', 'K': 'LYS', 'M': 'MET',
             'L': 'LEU', 'N': 'ASN', 'Q': 'GLN', 'P': 'PRO', 'S': 'SER',
             'R': 'ARG', 'T': 'THR', 'W': 'TRP', 'V': 'VAL', 'Y': 'TYR'}
  
  rPrS={'C': '102', 'A': '104','H': '12'}
  
  
  a=[]
  b=[]
  count=1
  for single, third in AMONIOACIDS.iteritems():
     for rS,rP in rPrS.iteritems():
         if rS == single:
              a.append(["s"+str(count)+"=selection(mdl1.chains["+chain+"].residues["+rP+"])"])
              b.append(["s"+str(count)+".mutate(residue_type='"+third+"')"])
  
  
  str='''Loop elements\n'''
  for i,j in zip (a,b):
      i=''.join(i)
      j=''.join(j)
      str+='''$i\n'''
      str+='''$j\n'''
  str=Template(str)
  str.substitute(i=i, j=j)
  file = open(os.getcwd() + '/' + 'model.py', 'w')
  file.write(str.substitute(i=i,j=j))
  file.close()
  </code></pre>
  
  <p>Expected ouput:</p>
  
  <pre><code>Loop elements
  s1=selection(mdl1.chains[A].residues[104])
  s1.mutate(residue_type='ALA')
  s2=selection(mdl1.chains[A].residues[102])
  s2.mutate(residue_type='CYS')
  s3=selection(mdl1.chains[A].residues[12])
  s3.mutate(residue_type='HIS')
  </code></pre>
  
  <p>What I am getting :</p>
  
  <pre><code>Loop elements
  s3=selection(mdl1.chains[A].residues[12])
  s3.mutate(residue_type='HIS')
  s3=selection(mdl1.chains[A].residues[12])
  s3.mutate(residue_type='HIS')
  s3=selection(mdl1.chains[A].residues[12])
  s3.mutate(residue_type='HIS')
  </code></pre>