File difference compare script using `difflib` module

import sys  
import difflib

try:  
    file1 = sys.argv[1]
    file2 = sys.argv[2]
except Exception as e:  
    print("Usage: ",sys.argv[0],"file1 file2.")
    sys.exit()

def readfile(filename):  
    try:
        file_open = open(filename, 'r')
        contents = file_open.readlines()
        file_open.close()
        return contents
    except IOError as error:
        print("Error: ", str(error))
        sys.exit()

if file1 == '' or file2 == '':  
    print("Usage: ",sys.argv[0],"file1 file2.")
    sys.exit()

file1_lines = readfile(file1)  
file2_lines = readfile(file2)

diff_obj = difflib.HtmlDiff(wrapcolumn=60)  
# wrapcolumn=60 set max column width to 60 characters

open('diff.html','w').write(diff_obj.make_file(file1_lines, file2_lines, context=True, numlines=0))  
# context=True, numlines=0 only show different part contents