Where are the input file and where do you want to save the output file. For this kind of scripts i think that it's better use absolute paths
Use:
open('/tmp/lista.txt', 'r') instead of:
open('/tmp'tmp/lista.txt', 'r') I think that the error can be related to this