Fix sync prefix bug

When doing a sync the second file and all the others after that will have the prefix doubled up. I changed it to use a separate variable while in the loop.