Fix writer reference for error printing