Yes, the code in the article will at one unlucky point end up with an empty file after a power outage.
At least write to a temp file(in the same filesystem), fsync the file and its folder and rename it over the original.