Your indentation is incorrect, so
w
only exists in the for loop. It should be:
for w in check_box_list:
if w.var.get() == 1:
w.destroy()
check_box_list.remove(w)
data = w.var.get()
filename = "grocery.pkl"
output_file = open(filename, 'wb')
pickle.dump(data, output_file)