In your loop, you're always writing 255, 0, 0
. That's a triplet of red, green, blue. The write of 255
above the loop specifies that the maximum value is 255. The width of your image is 256 pixels. There are 256 values in the range [0, 255]. Thus, it is fairly simple to deduce that the red component should be the X value. You could modify your code to look like this:
f.write("%d, 0, 0 \n" % x)