<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _write_adminfile(kwargs):
    '''
    Create a temporary adminfile based on the keyword arguments passed to
    pkg.install.
    '''
    # Set the adminfile default variables
    email = kwargs.get('email', '')
    instance = kwargs.get('instance', 'quit')
    partial = kwargs.get('partial', 'nocheck')
    runlevel = kwargs.get('runlevel', 'nocheck')
    idepend = kwargs.get('idepend', 'nocheck')
    rdepend = kwargs.get('rdepend', 'nocheck')
    space = kwargs.get('space', 'nocheck')
    setuid = kwargs.get('setuid', 'nocheck')
    conflict = kwargs.get('conflict', 'nocheck')
    action = kwargs.get('action', 'nocheck')
    basedir = kwargs.get('basedir', 'default')

    # Make tempfile to hold the adminfile contents.
    adminfile = salt.utils.files.mkstemp(prefix="salt-")

    def _write_line(fp_, line):
        fp_.write(salt.utils.stringutils.to_str(line))

    with salt.utils.files.fopen(adminfile, 'w') as fp_:
        _write_line(fp_, 'email={0}\n'.format(email))
        _write_line(fp_, 'instance={0}\n'.format(instance))
        _write_line(fp_, 'partial={0}\n'.format(partial))
        _write_line(fp_, 'runlevel={0}\n'.format(runlevel))
        _write_line(fp_, 'idepend={0}\n'.format(idepend))
        _write_line(fp_, 'rdepend={0}\n'.format(rdepend))
        _write_line(fp_, 'space={0}\n'.format(space))
        _write_line(fp_, 'setuid={0}\n'.format(setuid))
        _write_line(fp_, 'conflict={0}\n'.format(conflict))
        _write_line(fp_, 'action={0}\n'.format(action))
        _write_line(fp_, 'basedir={0}\n'.format(basedir))

    return adminfile