class UnicodeWrapper(object):

    def __init__(self, filename):
        self._filename = filename

def __iter__(self):
    with io.open(self._filename, 'r', encoding='utf8') as f:
        return iter(f.readlines())
if __name__ == '__main__':
    filename = '...'
handler = UnicodeWrapper(filename)
for line in handler:
    pass
How can I implement a file like class that always returns in UTF-8 encoding irrespective of file encoding?