I think that you'll need to change this so that the outputstream comes in as a method parameter.  This way, your writer, regardless of impl (local, s3 etc) can return it's own outputstream.  You can then pass the outputstream to this method, write to it, then close it when completed.  This should hopefully give you the streaming you need.