title: I am getting unexplained error in encoding program
body: <p>I am making a program that will encrypt a file through an offset factor. But I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "Y:\computer science\programming\year 10\controlled assessment\code.py", line 40, in &lt;module&gt;
      file1.write(chr(encode))
    File "C:\Program Files\Python35\lib\encodings\cp1252.py", line 19, in encode
      return codecs.charmap_encode(input,self.errors,encoding_table)[0]
  UnicodeEncodeError: 'charmap' codec can't encode character '\x88' in position 0: character maps to &lt;undefined&gt;
  </code></pre>
  
  <p>Here is the relevant bit of the code:</p>
  
  <pre><code>if choice == '1':
      a = open('saved.txt', 'w')
      a.close()
      file = open('sample.txt', 'r')
      file = file.read()
      thing = list(file)
      for i in range(len(thing)):
          encode = ord(thing[i])
          encode = encode + offset
          if encode &gt; 177:
              encode = encode - 177
          print(encode)
          file1 = open('saved.txt', 'a')
          file1.write(chr(encode))
      #file1.close()
      file2 = open('saved.txt', 'r')
      print(file2.read())
      #file.close()
      #file2.close()
  </code></pre>
  
  <p>But when I make the offset factor very small for example 1 or 2 then it works.</p>