When you load a sketch the EEPROM is erased. It is used to save data across resets and power cycles, not for saving data between sketches.

As Paul stated that is not what happens. The arduino bootloader and AVRDUDE do have the capability to read, write or erase the EEPROM memory, however the arduino IDE does not do that as part of a upload operation.

Where is the part that actually writes the EEPROM in the original code?

from:http://www.arduino.cc/en/Tutorial/EEPROMWrite"store values ... into the EEPROM using theEEPROM.write() function. These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch."