def read_file(filename):
    """ Read a text file line by line and remove empty lines. """

    with open(filename, "r") as infile:
        contents = infile.readlines()
        contents = [line for line in [line.strip() for line in contents] if not len(line) == 0]

    return contents