A possible appendfile approach?
Detection
exists it whose (not exists lines whose (it starts with "192.168.100.47") of it) of (if (windows of it) then (file "hosts" of folder "drivers\etc" of native system folder) else (if(unix of it) then (file "/etc/hosts") else (if(mac of it) then (file "/etc/hosts") else ("/etc/hosts")))) of operating system
Action
parameter "hostsfile"="{pathname of (if (windows of it) then (file "hosts" of folder "drivers\etc" of native system folder) else (if(unix of it) then (file "/etc/hosts") else (if(mac of it) then (file "/etc/hosts") else (false)))) of operating system}"
parameter "newhostsfile"="{((concatenation "%0a" of lines of file it) & "%0a192.168.100.47%09myhost.mydomain.com") of (parameter "hostsfile")}"
delete __appendfile
appendfile {parameter "newhostsfile"}
delete {parameter "hostsfile" & ".bak"}
copy {parameter "hostsfile"} {parameter "hostsfile" & ".bak"}
delete {parameter "hostsfile"}
copy __appendfile {parameter "hostsfile"}