Fixing multiline parsing to preserve newlines

Fixes #8813