for i in range(2):
    file.append(open(sys.argv[1 + i], 'r'))
lines.append({})
counter = 1
while 1:
    line = file[i].readline().encode()
if not line:
    break
hashcode = hashlib.sha512(line).hexdigest()
lines[i][hashcode] = sys.argv[1 + i] + ': ' + str(counter)
counter += 1
unique0 = list(lines[0].keys()) - list(lines[1].keys())
unique1 = list(lines[1].keys()) - list(lines[0].keys())
result = [lines[0][x] for x in unique0] + [lines[1][x] for x in unique1]
Quickly find differences between two large text files