Explicitly close file in get_encoding