Thanks all of you for the scripts. Now I have a few examples that work. Just for fun I created a large file and timed both solutions and the second one was about 45% faster. And I have also decided to finally learn some perl, and this provided me with a good problem to begin studying. Olle