Replace snprintf use with stringstream.