converting to python. file io with cpp is complicated