Hosts file not working for WinXP

A side-effect seems to be that my machine now resolves new DNS queries much faster too!

The problem was diagnosed with these commands:

 C:\> ipconfig /flushdns

This worked OK, and cleared out the DNS cache.

 C:\> ipconfig /displaydns

This returns this error when the hosts file was corrupted or missing:

Windows IP Configuration

Could not display the DNS Resolver Cache.

Had an odd problem recently, in that my local hosts file wasn't being used to resolve domain names.

Much Googling later I found this thread, which prompted me to try editing the hosts file using edit from the windows command prompt. It worked, and now my hosts file is being used again!

The displaydns option should show locally-defined host information (from hosts) when all is well.

The relevant comment from the thread mentioned above was:

I'm fairly sure it's an obscure bug in the name resolution system.
For example, if I edit the file using NOTEPAD, it still doesn't work.
But I've just found that, if I edit it with an old MS-DOS editor, then
remove the change and save the file (so the only difference is a
Ctrl-Z at the end of the file) it then starts to be used in name
resolution.

The file that doesn't work ends 0D 0A.
The file that does work ends 0D 0A 1A.

(But it shouldn't be necessary in 2004 to stick Ctrl-Z at the end of
the file, like we are still using CP/M).