I'd also add that 'for a while is more flexible because you can use it at the beginning of the sentence, whereas 'awhile' is generally only used after the subject and verb
E.g. For a while, we wandered OR we wandered for a while.
Sit here awhile, and sing to me, but NOT awhile sit here and sing to me.