Replaced sprinf_s with string stream