You open the file for writing on each iteration. This truncates it to zero length before writing. Try opening the file before the loop and leaving it open until after the loop completes.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401