this worked perfectly thanks. I just have a question about how it works? it seems like the assigments of $1 remove that section from the original variable. is that correct? can someone explain how that works in order to keep the pointer for the while in the correct place.