I ran the write command to change the safari homepage and then I ran the read command and it showed the new homepage. When I open safari, it didn’t change.
Where did you get those commands? There’s no “com.apple.Safari” domain on my Mojave system. There is one on my El Capitan machine, but it contains neither a “HomePage” key nor any mention of my Safari home page. On my Mojave system, it’s possible to read the home page setting from “com.apple.Safari.SandboxBroker”, but setting it that way doesn’t seem to be entirely effective — which is good. It would be an obvious security issue if a script were able to change a brower’s default home page!