import sys filename = sys.argv[1] path = sys.argv[2] fIn = open(filename, 'r') fOut = open(filename.replace(".","_path."),'w') for line in fIn: fOut.write(path+ line) fOut.close() fIn.close()