On line 2, notice the exceedingly terse grammar that is a key feature of Classical Chinese, a high context language (= if something can be inferred from context, it need not be stated explicitly):
夜宿廈間 [literally] night, sleep, back-of-house, room
= At night he slept in a room at the back of the house
Here, there are no prepositions whatsoever. What a cool sentence structure!