If I understood correctly what you mean, try to put this before returning the file:
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=$filename");
and hope that IE will prompt the "Save as" dialog box instead of opening the file. If it still doesn't work, remove the filename=$filename part (IE would guess the file format from its .doc extension; it's not HTTP standard, but MS doesn't care).