Changed output to file to stdout. Also fixed 32-bit int issue