<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_env(fname=None):
 """Generate file with exports. By default this is in .config/genomepy/exports.txt. Parameters fname: strs, optional Name of the output file. """

    config_dir = user_config_dir("genomepy")
    if os.path.exists(config_dir):
        fname = os.path.join(config_dir, "exports.txt")
        with open(fname, "w") as fout:
            for env in generate_exports():
                fout.write("{}\n".format(env))