def find_sentence_starts(data):
    """Finds the positions inside a memory-mapped file, where the sentences
    (lines) start.

    TextIOWrapper disables tell() when readline() is called, so search for
    sentence starts in memory-mapped data.

    :type data: mmap.mmap
    :param data: memory-mapped data of the input file

    :rtype: list of ints
    :returns: a list of file offsets pointing to the next character from a
              newline (including file start and excluding file end)
    """
    result = [0]
    pos = 0
    while True:
        pos = data.find(b'\n', pos)
        if pos == -1:
            break
        pos += 1
        if pos < len(data):
            result.append(pos)
    return result
