I\'m always getting a segfault when trying to run the code. I think it is caused by the last lines fclose(file) and fclose(img), but I don\'t really seem to understand why e