diff --git a/util.py b/util.py
index 88daf5b85dce9bc4f63f32d0d262cd46e7451782..cf5d63de41c76f8eee9238ba110a7885cc7c0aa9 100644
--- a/util.py
+++ b/util.py
@@ -42,7 +42,7 @@ def detect_encoding_and_open(filename):
     """
     raw_data = open(filename, 'rb').read()
     detected_encoding = chardet.detect(raw_data)['encoding']
-    encodings = [detected_encoding['encoding'], 'utf-8', 'ansi']
+    encodings = [detected_encoding, 'utf-8', 'ansi']
     for encoding in encodings:
         f = open(filename, encoding=encoding)
         try: