"Please wait in the hallway."
Think of に as more concerned with movement such as a physical destination or even an intangible goal (sometimes also an origin but I haven't seen that on duo yet)
The particle で gives context to your sentence. You're not moving to the library. You are simply reading and it happens to be in the library.
で is a particle with many uses, one of which is to say where you do something. For example 「としょかんでべんきょうしました。」"I studied at the library." 「ベッドでねました。」"I slept in my bed." 「かのしょといっしょにこうえんでさんぽしました。」"I walked with my girlfriend in the park."
I hope that was helpful.