as input file existance is not guaranted you should open output file after input file check:
if (inn.is_open()){
ofstream out (out_name.c_str(), std::ios::binary);
.....