Your echo command isn't right (keystroke would be a System Events command if it wasn't in a text string), but you should be seeing the incorrect text in the hosts file. The statement should be more like
set hostToAdd to "echo " & linefeed & quoted form of x & linefeed & " >>"
... but really all you need to do is use a text editor that is designed for these kinds of things, such as TextWrangler or BBedit. Either of those can navigate to the hidden folders and edit the file directly, including admin authentication.
You Can use Apple Script along with Automator to create an App that will allow you to Edit the host file.
1. Open Automator
2. Selection Application and click the choose button to continue.
3. Under Library - Search for: Run AppleScript
4. Drag the "Run Apple Script" action model over to the right hand pain.
5. Copy and paste the follow command: do shell script "sudo open -t /etc/hosts" with administrator privileges
- You should be pasting the command where it says (* Your Script goes Here*)
6. Compile - using the Hammer icon
NOTE: The results of your efforts should mirror my example below.
Lastly you can test things out to see if they work by click Run.
Once you confirm you have things working for your needs you can use the file menu to Save the finish product to your desktop as an app.
NOTE: you will be prompted for your admin account and password
Keep In mind the apple script command being used along with Automator is going to run your default TextEditor.
It appears that your duplicate post issue has been resolved - BUT - the bigger issue might be all the time you spent crafting a very nice post to a VERY old thread - thus creating what we fondly refer to as a "Zombie Thread"
Worry not, we all have done such things - but most have learned a lesson
Keep up the good work, though...