Try to replace the imwrite line in your loop with something like (with k
being your loop increment):
filepath{k}=fullfile(imgpath,T_MODE,keyword,strcat('img_',num2str(count_save),'.jpg');
imageSize{k}=size(im);
Run the loop once and browse through the resulting cells to see if the name of the file is always different (otherwise it will overwrite the existing files) and that the size of the images are not zero. Then you will have ruled out two reasons for your images not saving.