Never occurred to me that it could be a bug. I will try the trim and left options and see what happens. But the trim/left options would essentially be the same thing as the way that I have done it. A workaround to fix a bug in the readprofilestring command. I just assumed that I was doing something wrong in the coding.

What I will do first is get my code working without the handle, file open first to reduce unnecessary code. I just assumed that I needed it because I have always used handles when opening text files. Not sure why readprofilestring doesn't seem to need it as it's still opening a file which could be locked for some reason.