You delete content of entire FLASH memory when you erase FLASH before programming PIC.
Try this:
Code:
DEFINE OSC 24
 
X var byte
Y var word
Value var byte

Pause 4000      
Y = $500 
Value=2
                                                       
erasecode Y                                   
for X = 1 to 16                                 
writecode Y, Value                         
Y = Y + 1                                       
next X

Blink:
   readcode $500, Value
   If Value = 2 Then 
      Toggle LED    
      Pause 500
   Else
      LOW LED    
   Endif
   GOTO Blink