Unfortunately this did not seem to work. I implemented your suggestions but my script fails in the exact same way i.e. it gets to a file which it cannot read but the is_readable function returns that it is readable and my program proceeds to try and execute code which can't possibly succeed i.e. diffing two files, one of which it can't read.