Remove unnecessary slice and write to the writer while processing