in reply to my old robot

You should tie the file globally, that is, outside the "del" subroutine. The best place is probably just after "open".

But then, don't read the file in "while" - you can just use the tied array instead.