Better of reading from file

Hi all,
I have file to read somting like this

T SKKSD SKKDS SLLDSK
K SKDK 994 434 4343
A 494 DKLKLD SDFD
H LSDKLDSK DSDSDS
U KDS 0DS SD SDF99SD DFSSD
D DSK SDK94094 3

Based on first field (Ex: for line T) , I need to write this content in to files
if firsr field is T then corresponding line shold go to file1 and file2.
if first field is A then corresponding line shold goto to file1
if first field is K OR H OR U then line shoud to file2
if first field is D the line shoudl go to file1 and file2
Please let me know best way of doing this ..

I have done using do while loop. I wanted to know better way doing this.
I just wanted to validate my code with other smart brains

Thanks.

hi,
I just give you a sample, you can follow this way to address your issue.
In follow case, there will be file created and both have the same value of echoed.

code:

echo T SKKSD SKKDS SLLDSK | sed -e '/T/ w file1' -e '/T/ w file2'
awk '/^[TAD]/ { print > "file1" }
/^A/ { next } 1' filename > file2

I will try this. Thanks.