I need some help into figuring out how to split a text file into two files in java.

I have a text file in which each line contains in alphabetical order a word a space and its index, i.e.

```
...

stand 345

stand 498

stare 894

...

```

What I would like to do is to read in this file and then write two separate files. One file should contain only one instance of the word and the other the positions of the word in the document. 
The file is really big and I was wondering if I can use an array or a list to store the word and index before creating the file or if there is a better way.
I don't really know how to think.