How to split one text file into multiple text files according to text content?

HI,

The above sample just shows filename and content in MessageBox

How about if there are 2 or more same company name, merge them, as the following?
This sample actually output text file in project folder.

Sample20221117-4v2.zip (3.1 KB)

Regards,