Replacing the contents of a file using Nova APIs

I’m having some trouble replacing the contents of a file. The API allows data to be appended or overridden with nova.fs.open(…).write, but if the file’s offset is the beginning of the file, and the new content is shorter than the previous content, the ending bits of the previous content will remain.

Opening a file in write mode with “w” truncates the file, meaning that the first call to the .write() method replaces all of the file’s contents.