The problem is that only the last line is printed. Correct? I suggest that you add std::endl in your while loop. It can make the issue more clear.
www.google.com.tw