Your sketch works fine for me on a Diecimila. I upload the sketch, run it, see the expected output, comment out the write line, re-upload it, re-run it and see the same output.
Are you using something other then the IDE and USB port to upload your sketch? Perhaps and Flash and EEPROM are being cleared as part of the upload.