Symfony: Export (CSV) File has limit?

  download, symfony, symfony5

I’m trying to send a generated CSV file using Symfony 5 and somehow seem to have reached a limit I can’t overcome.
For testing reasons I have broken it down to the basic of the basics; so I send static data, generate a txt-file and do no logic whatsoever. In my example code below, if I do 65 iterations the file is generated and sent to the browser as a download (that’s 4KB). If I do 66 or add a single letter to the $data sample data string it’s all displayed in the browser window.
The exact same code works perfectly well outside Symfony even with 1000 iterations. I also don’t get an error or anything out of the dev.log that could help.

public function saveCSV(Request $request, DelcampeParser $parser) {
    $response = new Response();

// same with
//  $response = new StreamedResponse();
//  $response->setCallback(function(){});

    $response->headers->set('Content-Type', 'text/plain; charset=utf-8');
    $disposition = HeaderUtils::makeDisposition(
    $response->headers->set('Content-Disposition', $disposition);

    $data = array(0 => 'abcdefghijklmnopqrstuvwxyz');
    for ($a=1;$a<=66;$a++) {

    return $response;

What’s wrong? Why am I not able to generate a bigger file in Symfony?

Thank you.

[edit] I have a new theory: PHP’s output buffering is set to 4KB. Whenever the buffer is full, buffered data is sent to the Browser. That unfortunately happens before the headers have been sent by Symfony, thus generating a browser output. How can I change that behavior?

Source: Symfony Questions