Thanks for the reply Lew. Yeah, currently the 1st update reads all the files with clearflag = 'Y' - which incidentally still seems to be working, it's not until we try come write to the file in a later function that we get a problem. Have tried manually deleting and recreating the file with chmod 777 before starting the process, but got the same problem.
I could understand the problem if it was something that wasn't working previously, but it's worked fine like this for years. I may try simply deleting the file manually and allowing the process to recreate it, to see if this makes any difference.