line.strip() removes the line.strip() newline from the read line.
If you need this new line, you do not need to do this, I donβt think (does your output file have new lines)?
This if stripped bit searches for an empty string and was in the original a characteristic of loop completion.
This is not your graduation marker. You do not want to stop there. So do not do this.
The loop will end on its own when sys.stdin reaches the end of input ( EOF ).
Drop line.strip() drop if not stripped: break replace result = result + stripped with result = result + line and then write it to a file to get a simple (albeit very expensive) cp script.
There are probably more efficient ways to read all the lines from standard input if you want to do something with them (depending on your purpose).
source share