Besides checking whether the path exists or not, it should also check if `ofile` exists and that it's not a directory, This should also fix  #13098