The easiest way would be to read the first file, and then read the second file line by line, and perform a search & replace for each one. Depending on the size of the files and the number fo replacements, that might be slow, but probably it would be fast enough.
If the file is large (at least MBs) and the number of replacements is large (at least hundreds, probably thousands), then you might get to the point where that method is not fast enough.
In that case, read the second file in to a dictionary, and then do a single search and replace, something like:
It would take some effort to learn exactly how to do this, but I suspect if you figure it out, you'll have learned a tool (sed) that will be invaluable. I've never used sed, but I worked with a guy who could do almost anything using it (and some other commands like it).
Like I said, I know this was a one-off, but I thought I'd mention it.
As someone who learnt sed and awk a couple decades ago, I will suggest instead you just learn perl. sed and awk have very specific and peculiar and unique syntaxes and are quite limited in what they can do, whereas perl has a very specific and peculiar and unique syntax, but can easily do everything either of them can do and anything else text-parsing wise. Or anything-wise really. perl is my go-to language for scripting, and while it is old and clearly the developers fell off the rails a long long time ago, and python is a lot more popular these days, your time spend learning perl would be much better spent than time spent learning sed or awk. IMHO.
In any event, Keyboard Maestro can do this pretty trivially, and I expect it would be fast enough even with 100k rows. The slow part is setting up the dictionary. In a quick test I ran, Keyboard Maestro can process about 250 lines per second creating the dictionary, so 400 seconds to set up the dictionary. If the dictionary is fixed, then this can be done once and never needs to be done again until the dictionary changes. The actual search and replace is pretty quick, depending on the size of the tile and the number fo changes.
Thanks for that (perl), Peter. I will definitely look into it. I love having more tools, regardless of whether they're software tools, or woodworking tools.