Updated File::replace() method