Modified print statements
Fixed fclose location