How to force file checkout?

In my plugin, I open a file (using, and then if it's not writable, I invoke fireReadOnlyModificationAttempt() on its document. It prompts and performs the checkout as expected. But then doc.isWritable() still returns false, and any attempt to modify the file fails. If I invoke my plugin again (now that the file is checked out), it works fine. It just seems like I can't check out the file and write to it in the context of one EditorWriteActionHandler.

Am I doing something wrong? Is there a workaround to this?