title: KeyError in Python Script
body: <p>I've tried debugging this script but I'm not sure waht's causing the error.</p>
  
  <pre><code>list1 = ['&lt;p&gt;Text ([0-9]):(.*)&lt;/p&gt;' ,'&lt;p&gt;Text2 ([0-9]):(.*)&lt;/p&gt;','&lt;p&gt;Text ([0-9]):(.*)&lt;/p&gt;']
  list2 = ["&lt;p class='text'&gt;Text \1:\2&lt;/p&gt;" ,"&lt;p class='text'&gt;Text \1:\2&lt;/p&gt;","&lt;p class='text'&gt;TEXT ([0-9]):(.*)&lt;/p&gt;"]
  translation = dict(zip(list1, list2))
  
  
  pattern = re.compile('(%s)' % '|'.join(dicts.list1))
  file.close()
  file = open(args.file,'r+')
  def translate(match):
      return dicts.translation[match.group(0)] 
  with open(args.file, 'r+') as output:
          with open(args.file, 'r+') as book:
              for line in book:
                  output.write(pattern.sub(translate, line))
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>    return dicts.translation5[match.group(0)]
  KeyError: '&lt;p&gt;Text 1:1-1&lt;/p&gt;'
  </code></pre>