Header("Content-type: application/octet-stream");---------------------
Maybe because it is a stream, not a file.