Fixed file descriptor leak (hopefully)