I read that a program should close files after writing to them in case there is still data in the write buffer not yet physically written to it. I also read that some langua
Yes, it's better to close file after reading is completed.
That's necessary because the other software might request exclusive access to that file. If file is still opened then such request will fail.