generalized to allow non-line-delimited serializers