This question already has an answer here:
Then department.txt becomes empty, without any output. If i use some other file instead of the same file which i am reading, then it works.
I understand i am reading and updating the same file, but as per my understanding is | should take care of it, as internally it must be storing the the output somewhere in its memory and dumping it in the file which i have asked. Isnt it ? Can someone throw some insight on how it works ?
Note: I know there are many similar questions, but none of them have really answered how internally
| works, which is the fundamental question for which i need an answer.