How to append a character to the last but one field on a specific line?

Hi Guys,

I have a file like this:

aaa  b c d e f 
fsss  g h i  k l
qqq   r t h n 
 

I want:

aaa  b c d e  f 
fsss  g h i  k  l
qqq   r t h  ,  n 
ggg   p t e d u 
qqq   i o s ,  k
 

So I want to insert a comma at the last but one location of every line that matches "qqq".

I tried to use the gsub command but could not get the second from last character to be inserted in awk.

Thanks in advance.

awk ' /qqq/ { sub(" [^ ]*$"," ,&") } 1 ' file

Ok that script works when the row with the qqq has only one field missing. How can I modify the script if there are one or more fields missing for every row with qqq?

For example if I have: (i have used "a" instead of "qqq")

a b c d e f 
a f g u  i
a r d  u
a n

So I want:

a b c d e f 
a f g u  , i
a r d ,  , u
a , ,  ,  , n

Basically I want the last character on a line that matches "a" to line up with the column that has the maximum fields.
Thanks again.