Found the problem.
First off, line 31 is useless. It is from a past attempt and I forgot to remove it, so ignore it altogether.
Second, the error is in line 24. I constructed the FileOutputStream wrong. I used...
This will delete the file if it exists. But this...
... will make it append to the end.
The final product (before I start adding stuff):
@Amit: I only wanted to give credit where it was due. I had code before seeing this link, but it wasn't working like I wanted. What I have now is a derivative of the code found there.