Thank you both, disabling delayed expansion was the solution. Yzöwl - Yes, the small script and input file shown was just to demonstrate the problem and as you suggested is part of a larger script which includes the removal of text lines at the beginning and end of the input file. Also spot on about delayed expansion being enabled by default, seemed a good idea when it was setup and has now been amended. Am learning - but s-l-o-w-l-y. Again, thankyou.