The first example looks the cleanest to me. Could you please implement that?

The second example has exactly the same bug of calling `touch` twice, so no that is not a good solution.