def chunkstring(strng, length):
    """ Break a string on word boundaries, where each line is up to
    length characters long """
    ans = []
    line = []
    for w in strng.split():
        if len(w) >= length:
            ans.append(" ".join(line))
            ans.append(w)
            line = []
            continue
        if len(" ".join(line)) + len(w) < length:
            line.append(w)
        else:
            ans.append(" ".join(line))
            line = []
    ans.append(" ".join(line))
    return ans