Your flash is write only.
Writting to flash is not just a matter of writing to flash. In order to write to a flash, you must firt erase the "sector," then write to it. Your data is contiguous on the flash. So, to insert a new bit of information, you need to "push" the rest of the information towards the end of the flash.
With that in mind. Look at the paragraph above. Replace "Writting to flash is not just........." with "Writting to your flash is not just............" In order to insert the "your," you must copy the entire section of code from flash, store it in some place like RAM, erase some number of "sectors" depending on the code size, insert "your", then write it all back to flash.
Take a look at your flash data sheet, it will give you a better idea of what is done during a flash write.
Doug