Extract function with essential code, to avoid discussion of irrelevant stuff like \n vs std::endl ;)