Fixed file descriptor leak