in reply to exit the loop corrected

Amoura,

Please, always use strict;. It may take you extra time to get something working, but it will be well worth it. Another thing you may want to do is use diagnostics;. This will give you more insight as to what the problem is.

Would you please post an example file in your scratch pad? It doesn't have to be real, just an idea of what to expect.

Thank you, Kristofer