fclose was mising, fixed it