There are places where a while has to be two words.
...for a while...
...in a while...
...a while ago...
...a while back...
...spent a while...
There are other places where it CAN be one word but where it also CAN be two.
...They were together awhile/a while.
...We were there awhile/a while.
Moral of the story: Make it two words all the time -- end of story.
Happy punctuating!
Margie