def write_results_to_file(out_filename, commands, node_list, return_codes,
    stdouts, stderrs):
    """ Print the output of wait_for_all_results to a file.

    Parameters
    ----------
    out_filename: string
        Path to the file

    commands: list of strings
        The commands distributed to the cluster

    nodel_list: list of strings
        The nodes to which each command was sent, given by 
        ssh_utils.distribute_all

    return_codes, stdouts, stderrs: lists of strings
        The strings to write to disk. Presumably, the values returned from 
        wait_for_all_results.

    Returns
    -------
    None, but the file is (overwritten) with the text
    """
    with open(out_filename, 'w') as out:
        for i in range(len(return_codes)):
            out.write(commands[i])
            out.write('\n')
            out.write(node_list[i])
            out.write('\n')
            out.write('return code: {}'.format(return_codes[i]))
            out.write('\n')
            out.write('stdout: {}'.format(stdouts[i]))
            out.write('\n')
            out.write('stderr: {}'.format(stderrs[i]))
            out.write('\n')
