Your program works fine.
If you mean with "program cuts off" that the window closes before you can see the output. Call it from the commandline or search the forum.
Kurt