changing the file descriptor to global variable