Transmigrated as the doomed villain of his own novel, a writer must outwit fate—or die in every ending he once wrote.