SimpleXLSXGen: saved excel file is showing to be corrupted

I am trying to save an excel file in PHP using the SimpleXLSXGen library. This is my code:

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    header('Content-Type: text/plain; charset=utf-8');

    require __DIR__.'/vendor/shuchkin/simplexlsxgen/src/SimpleXLSXGen.php';
    use ShuchkinSimpleXLSXGen as SimpleXLSXGen;

    $arr = array();

    /*some logic here to populate my array*/

    $xlsx = new SimpleXLSXGen;
    $xlsx::fromArray($arr)
        ->setDefaultFont('Courier New')
        ->setDefaultFontSize(12)
        ->saveAs("..files/file.xlsx");
?>

This code used to work before, but now when I execute it, I keep getting a corrupted excel file saved at the location. Everytime I open the file, it keeps showing:

Excel cannot open the file ‘file.xlsx’ because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file

I have also debugged the $arr that I am pushing into my excel file, and it has the correct values. So why is the saved excel file showing to be corrupted?