def parse_file(filename):
    """Read a recipe file and return the data as a dict{name, body}. 
    Return None on failure.
    """

    try:
        recipe_dict = {}
        with open(filename, "r") as file:
            contents = file.read()
            recipes = contents.split("\n\n\n")
            for recipe in recipes:
                rows = recipe.split("\n")
                name = rows[0]
                recipe_body = "\n".join(rows[1:])
                if not name in recipe_dict.keys():
                    recipe_dict[name] = recipe_body
                else:
                    raise Exception("Recipe with given name already exists.")
        return recipe_dict
    except Exception as e:
        print(e)
        return None