Thanks for your help. I copied part of the code from a book which wasn't too clear on whether the array items would be split on whitespace or be lines. I see now that they are lines. What you have suggested is pretty much what I had in mind. I take your point about variable names, I guess I wasn't being very imaginative :-).
Cheers
S.