Added file closure in bothe server and client