The first thing to look for is trying to empty widgets by undef'ing them. When you edit successive files, are you undef'ing the old text widget, and creating a new one for each file? That would be my first guess without seeing your code. If it is correct, you should reuse the same text widget, just empty it and delete all tags and text, before loading the next file.