Create archive file (.zip) that contain text files

Hi, I’am trying to create a .zip file on the fly that contains xml files, since I’am beginner I started with a simple example that is : create archive file that contain a text file. I successfully create it but after I download it, this file could not be opened An error occurred while loading the archive. this is in case of filling the archive with text file that contains a simple string: here is my essay:

val enumerator = Enumerator.outputStream { os =>
          val zip = new ZipOutputStream(os);
          zip.putNextEntry(new ZipEntry("test.txt"))
           zip.write("Here are 100000 random numbers:\n".getBytes("utf-8"))
    Ok.chunked(enumerator >>> Enumerator.eof).withHeaders("Content-Type"->"application/zip" ,

However When I inspect the response from the browser I found this error: Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
I have been a while figuring how to resolve it but did not work?
and is it possible to stream an enumerator to the archive file?