I have a perl script with looks to see if a file exists or not then if it does passes the right information for the file to be downloaded but if the files does not exist I pass a 404 Not Found HTTP status. My problem is that if the file does not exists the 404 status is not being sent right. When run a linkchecking program or check my IIS server logs any borken links using this perl script show as 200 Ok status but out side the perl script all the broken links are recorded properly. Below is my perl code, can someone help me figure out what is wrong?