Fix writer mem leak