Added manual close of file descriptor