For this project i need to have the ability to analyze a file containing a number of .NET(3.5) class's from source code.. identify every class and then output each seperate class into their own text file

i.e(this is what the file is like, contains a number of class's in it, one after another))
[class 1 attributes]
class 1

[class 2 attributes]
class 2

What do you think would be the best way to do this?

What i was thinking of doing is somehow using regex's to identify [attributes] and the beginning of class's and then save the text(code) in between each.

I know how to read text from a file, use regex's and save text to a file, the only problem i have is somehow identifying and saving the text(code) for each class.

Would it be better to analyse the text line by line?

Any help in getting me started would be greatly appreciated and once i start develoiping code i will definitley post it up here for review!