Ok. The writevalue function should return an error code if it is the offending part of your script. Adding some debugging lines on strategic places in the script always helped me out.
Can you add the code below directly after the writevalue line and let us know what you get back?

 Code:
?@error
?@serror
sleep 10
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.