Fix: Ensure messages are sorted by line (fixes #1343)