A quick fix, using your code.... but tweaking it
Code:
For nLine = 0 To RTBLineCount - 1
        
        ccnt = ccnt + 1
        Charindex = SendMessage(RichTextBox1.hwnd, EM_LINEINDEX, nLine, ByVal 0&)
    
        RichTextBox1.SelStart = Charindex
        RowLength = SendMessage(RichTextBox1.hwnd, EM_LINELENGTH, CharIndex, ByVal 0&)
        ReDim Buffer(RowLength + 1)
        Buffer(0) = RowLength + 1

        SendMessage RichTextBox1.hwnd, EM_GETLINE, nLine, Buffer(0)
        LineText = Left$(StrConv(Buffer, vbUnicode), RowLength-6) ' single line, less 6 right cut.
        
...
Copy your current code before replacing this, just in case the tweaks affect something else you didn't show us.
Note that the variables i, FirstChar, CursorPos are no longer used in the above tweaks.