Output grouping fails on multiline print statement

When printing the same multiline message twice in a row, the output box shows the (x2) indicator, but duplicates the first several lines.

Here are several examples which show the pattern well.

> print("foo\nbar"); print("foo\nbar");
foo
foo
bar (x2)
> print("foo\nbar\nbaz"); print("foo\nbar\nbaz");
foo
bar
foo
bar
baz (x2)
> print("foo\nbar"); print("foo\nbar"); print("foo\nbar");
foo
foo
foo
bar (x3)

Grouping multiline messages might be confusing (does (x3) apply to this line, or the last n lines?) so I would advise against it altogether. However, even if grouping was still done on multiline prints, the last example should look like this:

> print("foo\nbar"); print("foo\nbar"); print("foo\nbar");
foo
bar (x3)