Close file after parsing and remove unused vars