def split_lines(text, lead='', tail='', width=74):
    """Split a string across multiple lines without 
dividing up words.  All combinations of whitespace 
characters are interpreted as a single space except
repeated newlines, which represent a paragraph break.

Optional keywords are:

'lead'  (def: lead='')
Indicates a string that will be inserted at the
beginning of each line.

'tail'  (def: tail='')
A string that will be inserted at the end of each
line.

'width' (def: width=74)
The maximum line width in characters.  If the lead 
and the tail add to more than 'width' characters,
then 'print_lines' returns -1.
"""
    NL = len(lead)
    NT = len(tail)
    tail += '\n'
    Nmax = int(width - NL - NT)
    if Nmax <= 0:
        return -1
    out = lead
    pars = text.split('\n\n')
    for par in pars:
        words = par.split()
        Nline = 0
        for word in words:
            NW = len(word)
            while NW > Nmax:
                if Nline > 0:
                    out += tail
                out += lead + word[:Nmax] + tail + lead
                word = word[Nmax:]
                NW -= Nmax
                Nline = 0
            if Nline + 1 + NW > Nmax:
                out += tail + lead + word
                Nline = NW
            elif Nline == 0:
                out += word
                Nline = NW
            else:
                out += ' ' + word
                Nline += 1 + NW
        out += tail
    return out
