convert string to stream c++

#include <iostream>
#include <sstream>

int main() {
    std::string str = "Hello, World!";
    std::istringstream stream(str);
    std::string word;

    while (stream >> word) {
        std::cout << word << std::endl;
    }

    return 0;
}