Replace assumeTrusted!fwrite with a nested trusted function