Leshy spritesheet creator text to plist script

I quickly adapted a python script to convert spritesheet exported as text from :
https://www.leshylabs.com/apps/sstool/
to .plist .
TexturePacker free giving me black edges around sprites (wrong padding).

init = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>frames</key>
        <dict>
        """

preblock= "<key>"
block= """</key>
            <dict>
                <key>aliases</key>
                <array/>
                <key>spriteOffset</key>
                <string>{0,0}</string>
                <key>spriteSize</key>
                <string>{"""
					 
firstblock="""}</string>
                <key>spriteSourceSize</key>
                <string>{"""
secondblock ="""}</string>
                <key>textureRect</key>
                <string>{{"""
thirdblock ="},{"
fourthblock = """}}</string>
                <key>textureRotated</key>
                <false/>
            </dict>
							"""
end = """        </dict>
        <key>metadata</key>
        <dict>
            <key>format</key>
            <integer>3</integer>
            <key>pixelFormat</key>
            <string>RGBA8888</string>
            <key>premultiplyAlpha</key>
            <false/>
            <key>realTextureFileName</key>
            <string>spritesheet01.png</string>
            <key>size</key>
            <string>{1010,1435}</string>
            <key>smartupdate</key>
            <string></string>
            <key>textureFileName</key>
            <string>spritesheet01.png</string>
        </dict>
    </dict>
</plist>"""

out = file('pfile.plist', 'w')
out.write(init)
for line in file('text.txt', 'r'):
#with open("text.txt", "r") as filestream:
#    with open("pfile.plist.txt", "w") as filestreamtwo:

#			for line in filestream:
	print line
	curline = line.split(",")
	string = preblock+curline[0]+block+curline[3]+","+curline[4]+firstblock+curline[3]+","+curline[4]+secondblock+curline[1]+","+curline[2]+thirdblock+curline[3]+","+curline[4]+fourthblock
	out.write(string+"\n")
out.write(end)