QTextEdit and QPlainTextEdit both store their contents as a QTextDocument. When you put text into QTextDocument that contains embedded newline characters, it is probable that these are stripped out and each segment converted into a QTextBlock. So searching for newlines doesn't work because they aren't there.

You can check this by asking the document for the blockCount(). You could also look at the result of characterAt() where you give it a known index of a newline in your input text.

You can retrieve something like the original text using QTextDocument::toPlainText() or QTextDocument::toRawText(), but see the comments for those methods regarding changes that could be made from the original input.