how to check eprom connected or not in runtime ?

using this if condition code it not checks runtime....

i want make like if i remove dongle thn msg prints "insert dongle" at runtime..

Wire.beginTransmission(80);

error = Wire.endTransmission();

if (error == 0)
{

  Serial.print("Connected");

}
 else
 {
  Serial.println("Insert dongle");
}

it works when i restart ardiuno not at runtime. i tried also using while loop also not works.

This code cannot be in setup() to behave in this way. You must put it in the loop(). Did you try:

void loop() {
   // your code here to test if your I2C EEPROM is connected.
   . . . 
   . . .
}