added the possibility to stream to a file