added the possibility to stream to a file

You can add an optional parameter, and stream directly to a file