Well, this isn't directly related to your problem, but you've used the same flag. So, in theory, if it worked at all, you'd get a door that kept opening and opening and opening....
So
try
if (ego_touching_signal_line ||
!done_flag) { // I prefer named flags
end.of.loop(door, done_flag); // some other flag
}
if (!ego_touching_signal_line) {
reset(done_flag); // This is a bit of a kludge as I
} // haven't used this kind of door
That's step one.
end.of.loop() should reset the variable when cycling and then set it when done.
Step two is easy: Download another game that has this door and steal their code. Right off the bat, I'd suggest V. you can get that at
www.agigames.com