Hi,
I see you tried the reprex package, but the output you're sharing makes even less sense than the first post 
I know it can be tricky to explain what you're looking for and share the correct code, but I won't be able to help you if I don't understand the problem and have some code I can run and look into...
Again, your question is about a loop, but I don't even see a loop or where there should be one. It seems you are trying to read in files, do some transformations and save the results again in a file.
Just try and create a good reprex one more time
PJ