Very bizarre bug I've been stuck on for a week. please help

Billy Babis

Hi there. I tried to simplify the code below as much as possible while still reproducing the error. 
Bug I'm facing:
It works on my mac laptop but when I try to run the same code on my windows VM, it only works half the time. That's correct: half the time the code works as expected.
What I'm trying to do:
I have a CSV of precipitation statistics for each county in the US (which I generated using a TIGER US county shapefile). Using that same TIGER US county shapefile, I'd like to add each county-level statistic as a property to each county in the shapefile. 
What's going wrong:
Half the time, nothing. It works as expected. Half the time, though, the new shapefile is created but none of the features have any properties. Either all features properly write the properties or none of the features have any properties. 
Of course, I can just run this code in a loop until it works as expected but obviously that is a terrible hack. Please help me try to debug what is going on here. I'm happy to attach the shapefile and csv but when I try to do so I'm told "Your message is too large"

Join to automatically receive all group messages.