An option would be to include the xk6-exec extension as well. With that, you could delete your file.
import file from 'k6/x/file';
import exec from 'k6/x/exec';
const filepath = 'sample-output.txt';
export default function () {
file.writeString(filepath, 'New file. First line.\n');
file.appendString(filepath, `Second line. VU: ${__VU} - ITER: ${__ITER}`);
exec.command("rm", [filepath])
}