下人は、頸{くび}をちぢめながら、山吹{やまぶき}の汗袗{かざみ}に重ねた、紺の襖{あお}の肩を高くして門のまわりを見まわした。雨風の患{うれえ}のない、人目にかかる惧{おそれ}のない、一晩楽にねられそうな所があれば、そこでともかくも、夜を明かそうと思ったからである。「羅生門、 芥川龍之介」
Second sentence (from 雨風の...) looks like {下人は}Xと思った, where X describes 下人's thought process ("If there were ... he'd spend the night there").
The sentences with からである that I've seen roughly involve a cause/reason, something like AはBからである - the reason for A is B. However, I can't see anything explicit (no A, so to speak) here to suggest the thing that could have spurred 下人's train of thought.
Question: how is からである used here? Why didn't the sentence end at 思った?