Read in the text line by line, then after each line, parse for spaces. Every time you spot a space, create another string with a substring of the whole line.
I don't understand the second question. The wording is too difficult to comprehend. Do you mean you want to empty out the text file?