once you get the loop working, check-out WriteValue in the manual.