Fix file handle leak in filter plugin