I found a solution, by casting the CString to a CStringA
myPrintMethod(CString stringtoprint, LPCWSTR myfile){
std::ofstream myfile;
CStringA output = T2A(stringtoprint);
myfile.open(filename, std::ofstream::out);
for(int i = 0; i < output.GetLength(); i++){
myfile << output[i];
}
myfile.close();
}