"A while" is an noun and "awhile" is an adverb. It sounds confusing but you already know the difference.