added frees for directive; added fclose on input file for debug path of main