This functions gives the user a chance to make the output file writeable before a write attempt is actually made by R to avoid having run the whole program again upon write failure.
wait_for_writable(
filename,
prompt_text = paste0("The file '", filename,
"' is not writable. Please close all applications using this file. Press '",
abort_answer, "' to abort!"),
abort_answer = "n"
)
TRUE if writable, FALSE if aborted by user or (not-writeable and non-interactive)
The file to test for writable
If not writable, show this prompt text to the user
If the user enters this string into the prompt, this function will stop()
Note: The file will not be overwritten or changed by this function.