import json


def read_file(filename):
    """
    Return contents of a file as list.
    """
    lines = []
    try: 
        f = open(filename, 'r')
    except (SystemExit, KeyboardInterrupt):
        raise 
    if filename.split('.')[-1] == 'json':
        with open(filename, 'r') as f:
            lines = json.load(f)
    else:
        with open(filename, 'r') as f:
            while True:
                line = f.readline()
                if not line:
                    break 
                lines.append(line.strip())
    return lines