ok, I just tried the suggestion of opening both output files b4 the main while-loop, but that doesn't work.
I did indent and put brackets in my code.....does it not show correctly in the 1st post?
btw, can I uhhhhhhhhhh see the code after you uhhhhhhhhh fixed it???

h: