so in my linux terminal I type python3 main.py input.txt > output.txt
input.txt contains:
This is line 1
This is line 2
This is another line
How do I go through this line by line and print out each line so my output.txt
looks like the output below? Essentially, I'm just asking how do I read this like by line? I can't use fopen
since I am making input.txt
like my stdin
This is line 1
---
This is line 2
---
This is another line
---
My question is different from the rest because here I am not opening a file using open()
. I am pipping the stdin input as input.txt
. As you can see in the command input.txt > output.txt
. So I cannot use open.