A while, a noun phrase, is used as the object of the prepositions for and in.
- Tom and Linda have decided to stay for a while in Otego.
- In a while, Tom and Linda leave Otego for good.
Awhile is an adverb that means for a time.
- Tom and Linda are deciding whether to stay awhile in Otego.