How to FlateEncode the data stream?

Q: I am struggling to successfully flate encode a stream. The code
example is as follows:

Filter myfile = new StdFile("out.bin",
  StdFile.OpenMode.e_write_mode);

// attach the output of ascii85 to myfile
Filter ascii85 = new ASCII85Encode(myfile);

// attach the output of flate to ascii85
Filter flate = new FlateEncode(ascii85);

FilterWriter writer = new FilterWriter(flate);
writer.WriteString("Hello World");
writer.Flush();

...results in an emty file.
We need to be able to take a file as input, and create a flate encoded
stream of that file. Hopefully also with some control over the degree
of compression. Do you have any suggestions?
---

A: You just need to use writer.FlushAll() instead of writer.Flush()