title: Opencv Imwrite is not saving images
body: <p>I have this code which converts a csv file to images. I run it with no errors. but nothing happens and imwrite is not working.</p>
  
  <pre><code>import csv
  import numpy as np
  import cv2
  
  file = open('fer2013.csv')
  dataReader = csv.reader(file)
  
  X_train = []
  X_test = []
  y_train = []
  y_test = []
  
  for row in dataReader:
      if row[0] == 'emotion':
          continue
  
      y = int(row[0])
      X_str = row[1].split(' ')
      X = [int(x_str) for x_str in X_str]
  
      if row[2] == 'Training':
          X_train.append(X)
          y_train.append(y)
      else:
          X_test.append(X)
          y_test.append(y)
  
  X_train = np.array(X_train)
  y_train = np.array(y_train)
  X_test = np.array(X_test)
  y_test = np.array(y_test)
  
  d = 0
  while X_train.all():
      for image in X_train:
              image = image.reshape((48, 48))
              cv2.imwrite('E:/EmotionRec/test/dataset/%x.jpg'%d, image.astype(np.uint8))
              d+=1
  </code></pre>
  
  <p>What's wrong with my code or probably my loop including imwrite?</p>