Also, the computer would know that the heroes would want the book to disappear, in order to prove a point to Moriarty.  It is extremely good at reading social situations, after all (heck, this is its main job, or the main job of the tiny corner of the computer that gets used for holodeck stuff at any rate). 
The same social graces would allow the computer to open doors at exactly the right moment, and to answer questions not actually asked, as happens all the time when the stupid users make queries.
But the mighty computer comes with subdivisions when needed: Moriarty, while a creation with some access, is not the same thing as the computer, say. But the holodeck part of the computer tries to make life enjoyable for User Moriarty, just as it helps out User LaForge. And User Redblock, when he accidentally gains user rights and demonstrates the wish to walk out of the holodeck. It's too bad that replicating a book (or making a replicated book disappear in mid-air) is trivial but keeping the imitation of a human alive beyond the doors is impossible beyond a point...
Timo Saloniemi