I had some trouble parsing what this big if-else block was trying to accomplish. Might be worth writing this as three explicit cases being (not sure of this proposal myself, but I feel there is room for improvement):

* The file does not exist, the `rotateIfExists` flag is irrelevant.
* The file exists and we want to rotate.
* The file exists and we want to append.

It may be preferable to even consolidate a file not existing and appending to a file as the same general case.