Adrian:
Thank you for the additional information. It seems to confirm my understanding that you are trying to create a text file where each SKU is a single line of variable length depending on how many product characteristics are passed. My suggestion remains the same. If a problem isn't easily solved, break it up into smaller pieces and conquer them individually. My second suggestion would be that, if all else fails, get your Adagio consultant involved.