When you try to visit "http://localhost/", you might only see 2 words on the page: It Works!
What is it ? Which web server you are using ?
The page “It Works” is the default apache Vhost. If you are getting this, it has nothing to do with the hosts file. Will need more information on the url you are trying to access and what you expect to happen.