closing the connection every file