Use temp file to save metadata for readonly file

OK, that makes sense. No problem I can see.