new version to write to ostream;