Problem with imwrite images

I created a function for finding the hough lines in an image, it takes my initial jpg image and everything turns out just fine and for the second time it takes an image created with the help of the imwrite function and throws errors like:

‘NoneType’ object is not iterable

welcome. you need to provide a lot more information. be forthcoming. anticipate questions.