Jos van Uden:
Another consideration, I just remembered, was that it avoided creating global variables.
Right, that's important, but every rule should be followed with a grain of salt.
First of all in this program there are no global variables, just a global immutable, filename. Global immutables cause far less troubles than global variables.
(In my opinion hard-coding the file name like that is not nice, but for this little program it's acceptable).
And second, this is a very small program. What's bad in a 100_000 lines long program is sometimes acceptable in a 73 cloc lines long program...
Bye, bearophile