You should not begin a sentence with 'for' when it means 'because'. Other meanings permit it. Good writers can do so for style because in the context a clause of explanation precedes 'for', as in your two examples.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.