Question: Im using auto layout for this imageView and I don't have a height set in the constraints thinking it would resize to the image height but it doesn't seem to work. Here is a pic: 

[![http://imgur.com/JtpTKVx](https://i.stack.imgur.com/aE88ym.jpg)](https://i.stack.imgur.com/aE88ym.jpg)

I want to remove the red space which is the background and just have the image

it is in a UITableViewCell which i want to size according to the image size.

Answer: 
Essentially, you'll need to read in the file. Then, check each line. If the line has something after you split on the equal sign, just output the line as is; otherwise, append a hashtag to the front and then output the line.

```
f = open(filename, "r")
lines = f.readlines()
f.close()

output_lines = []
for line in lines:
    if len(line.split("=")[1]) > 0:
       output_lines.append(line)
    else:
       output_lines.append("#" + line)
f = open("commented" + filename, "w")
f.write("\n".join(output_lines))
f.close()

```
You could also use this code to accomplish your task. The only restriction is that the empty variable is identified by no whitespace. E.g. 'v1='

```
MyFile=open("AFile.txt", 'r+');
newdata = []
data = MyFile.readlines()
for item in data:
    PosEquals = item.find('=')
    LenOfItem  = len(item)
    # Checks position of equals in line 
    # and also if there is anything after equal sign
    if PosEquals <> -1 and PosEquals <> LenOfItem-1:
        newdata.append(item)
    else:
        newdata.append('#'+item)
MyFile.seek(0)
MyFile.writelines(newdata)    
MyFile.close()

```