Why 2 files downloaded by the same code of php are different?

There are 2 php files

if($_SERVER["REQUEST_METHOD"]=="GET")
{
    if(isset($_GET['testo']))
    {
        if(logged($_GET['testo']))
    {
        $filename = "Demon.zip";
        $filepath = 'uploads/' . $filename;
    
        if(!empty($filename)&& file_exists($filepath))
        {
           $demo_name = "Demon.zip";
           header('Content-type: application/zip');  
           header('Content-Disposition: attachment; filename="'.$demo_name.'"');  
           readfile($demo_name); // auto download
        
            exit;
        
        }
        else
        {
            //comments
        }
    }
    else
    {
        //comments
    }
    }
    else
    {
        //comments
    }        
}
else
{
    //comments
}

From this file I can download from the server but the zip file I downloaded can’t be unzipped by an applications.

<?php
           $demo_name = "Demon.zip";
           header('Content-type: application/zip');  
           header('Content-Disposition: attachment; filename="'.$demo_name.'"');  
           readfile($demo_name); // auto download
?>

Instead this file can be downloaded and can be unzipped. I discovered that the size of the downloaded file from the first file is bigger than the another one… I don’t know why, the download code is same!!! How can I solve this?