Added some guard against os.remove() problem.