Awhile is an adverb that means "for a while," whereas "while" is a noun meaning "a period of time." Generally, you should use the two word form, "a while," when following a preposition (I will read for a while), or with the words ago or back (a while ago/back).