fix printGrid with ostream