Replaced hardcoded std::cout with std::ostream