for don in open('list.txt', 'r'): myURL=don myURL=myURL.replace("rep.php","") print(myURL+"test.php") It's printing
http://www.blabla.com blablabla.html When you iterate over a file handle, you get one line at a time with any trailing newline characters. So, the line is probably 'http://www.blabla.com\n'. That's why, when you append 'blabla.html', the result is split over two lines.
An easy fix is to do
print(myURL.rstrip() + 'blabla.html') On a side note, it's good practice to manage resources like file handles with context blocks so that the file handle is explicitly closed (and not left to the garbage collector):
with open('list.txt', 'r') as f: for don in f: ...
print(url)but we don't see where that variableurlis defined.print("DEBUG", repr(myURL), repr(myURL.replace("rep.php",""))you'll see the problem.