version before this could be a good one to go back to; trying to make thsi work on my local machine, but couldn't find any of the files that should have been written in the senc_sim_fun call; added more file-writing within the foreach loop