def nextWord(s, i0, ignoreNewLine=False):
    """
    Find word from position i
    :param s: text string
    :param i0: current position
    :param ignoreNewLine: pass newline, when search for word
    :return: word, positionJustAfterWord. None, None if end of string or newline encountered
    """
    if i0 >= len(s):
        return None, None
    allwhitespace = [' ', '\t', '\n', '\r']
    whitespace = [' ', '\t']
    if ignoreNewLine:
        whitespace = allwhitespace
    i = i0
    while s[i] in whitespace:
        i += 1
        if i >= len(s):
            return None, None
    if s[i] in allwhitespace:
        return None, None
    k = i
    while s[k] not in allwhitespace:
        k += 1
        if k >= len(s):
            return s[i:k], k
    word = s[i:k]
    return word, k
