def shorten_lines(string, lineLen, maxLines):
    """Truncates <string> to a certain number of lines.

    Keyword arguments:
        string -- <str>; the <str> to shorten
        lineLen -- <int>; the number of characters that constitute one
                   line
        maxLines -- <int>; the number of lines <string> can be at most
    """
    lines = string.split("\n")
    lineCount = 0
    newLines = ""
    for line in lines:
        length = int(len(line) / lineLen) if len(line) > lineLen else 1
        if len(line) > length * lineLen:
            length += 1
        lineCount += length
        if lineCount > maxLines:
            break
        newLines += "{}\n".format(line)
    return newLines