def word_wrap(string, width=80, ind1=0, ind2=0, prefix=''):
    """ word wrapping function.
        string: the string to wrap
        width: the column number to wrap at
        prefix: prefix each line with this string (goes before any indentation)
        ind1: number of characters to indent the first line
        ind2: number of characters to indent the rest of the lines
    """
    string = prefix + ind1 * ' ' + string
    newstring = ''
    while len(string) > width:
        marker = width - 1
        while not string[marker].isspace():
            marker = marker - 1
        newline = string[0:marker] + '\n'
        newstring = newstring + newline
        string = prefix + ind2 * ' ' + string[marker + 1:]
    return newstring + string
