Whaaaaa?

you should be doing the steps in this order:
1) open the file
2) for each contact in contactlist
3) write out the contact info
4) -next-
5) close file

that's it and nothing more... do you have a loop in a loop of some kind?

-tg