Rewrite part of snapshot feature to get connections correctly

I've tried to minimize the amount of code I'm touching to complete this. I'd prefer not to rewrite the entire class.
Erm, isn't this going to get into a condition where if it runs this code at the same time for two environments, it overwrites the temp file again and again?