added function to provide your own fileoutputstream