How to detect multi-line messages