> infile$ = "ad.txt" > outfile$ = "ad.csv" > infile=sys.argv[1] > outfile=sys.argv[1]+".csv" And these will give two different results. The QBasic version says "ad.txt" "ad.csv" whereas the python version will give "ad.txt" "ad.txt.csv" so you need to say infile = sys.argv[1] outfile = sys.argv[1][:-3]+'csv' or something equivalent.