Fix syntax of "if" to match javascript, and move the print code to the end of the files