file transfer can be easily done with python xmlrpc. it is very simple and spans a very few lines of code.. :) pls check this link to see how i done it...
Your program looks strange. You close file explicitely inside with block.