The way this is implemented destroys the contents of the file, so revisit if this causes issues in the future.