def orca_parser(filename):
    """ Parses energies from orca output files
    """
    with open(filename) as f:
        lines = f.readlines()

    if not  "ORCA TERMINATED NORMALLY" in lines[-2]:
        print(f"error reading {filename}")
        return 0

    for line in lines[::-1]:
        if line.startswith("FINAL SINGLE POINT ENERGY"):
            return float(line.split()[4])

    # should never get here
    raise SystemExit