added code for explicit file closing for bin/tac