Has anyone else got anywhere with trying to write to the flash memory at runtime?

I had a go at this last night and I think I am getting somewhere. It doesn't help that the datasheet is vague and occasionally inaccurate on the subject. This example code increments a variable and writes it to flash every time the reset button is pressed (after a 1.5 second delay the first time) - could people please test this and tell me if it works? If it works reliably then it might be possible for someone to develop it into some kind of EEPROM-emulation library.

if(nv_ram[6]!=9){ nv_ram[6]=9; nv_ram[42]=1; delay(1500); Serial.println("This is the first time I have been run."); // you probably won't see that unless you open the serial monitor quite soon after uploading } else { Serial.print("I have been reset "); Serial.print(nv_ram[42]); Serial.print(" time"); Serial.println(nv_ram[42]==1 ? "." : "s."); if(nv_ram[42]>10)Serial.println("Please don't reset me any more, as we don't know how many times the flash can be reprogrammed before it breaks."); if(nv_ram[42]>100)Serial.println("I said stop pressing the bloody reset button you idiot!"); nv_ram[42]++; } nv_save();