Can you please provide more information. That being:
1.) What is the output of your code? Does it crash? or is it able to run succesfully but your print statements are unsuccesful?
2.) Do the print statements print only “Photon Position” and "Copy number: " or do they not print at all?
3.) The code sample which you have provided here, where in your code does it reside? Is it part of the G4UserSteppingAction?