Because you're either not using binmode to write it to a file, running the code as a CGI and you don't set the correct headers (hint: you're not setting any) and/or not calling internet explorer correctly.
You really should show the EXACT code you're using.