Your comments

The data I need from the zmanim api specifically is the times - sunrise and sunset, mostly.

I worked through my own issue. In the end rather than print each line, I pushed each line into an associative array. Before adding a line, I check to see if it's already there AND that the tag is "parashat". If it is, I leave it. If it's not, I write (or over-write) the line. You can find the code on github:
https://github.com/adatole/sephardic_zmanim_fullyear

and you can see it running here:
https://clevelandsephardiminyan.com/wp-content/zmanim/fullyear.php