My script is now working as it should be. I took the best of what I had written and turned it into functions. Finger, Gopher, and Gemini are all displaying correctly after conversion from two HTML files.
I'm closer but I still don't have Gemini displaying properly. I was able to make a lot progress with my script in other ways though.
I've fixed the issue where posts did not display when I was fingered on Cluster and Meta Array. I'm now working on a fix for the posts link in Gemini.
Yesterday, I came close to fixing the display result from Finger, which isn't displaying these posts. Related to this, I fixed multiple blank lines from being displayed at the top of the screen from Finger, Gopher and Gemini.
I'm nearly finished with a scripting solution that from one file produces multiple files for different protocols. These protocols are served from two different types of systems, NetBSD and Debian GNU/Linux, each with their own requirements.
I've made a lot of progress with making this site work with different protocols.
Today is a new day! Goodbye WordPress and other over-engineered software.