replace file in place