Save Sections of HTML from one file to separate files

Greetings, I’m new and script challenged.

I’m working on a project where I want to take an old HTML page set up like a glossary and break out each entry into separate small HTML files.

I feel like I’m 85% there.
I open the HTML file in BBEdit and run a grep find with (<h3(?s).*?)top


That pulls each item from its Headline3 tag to its “Back to top” link.
I can get the Find All to make that list.

I’d like to save each of those items as a separate file.

I’ve gotten close with Automator and Script Editor using the record function to step through
Find Next
New (from selection)
Select the original file

However when it loops it doesn’t actually select the next chunk. The selected text is the same and it repeats the same file already created.

Any thoughts are appreciated.
Rb