Welcome to the Ranch
It is not usually a good idea to access CSVs directly; if you look in our
FAQ (under “Excel”) you can find some libraries to write and read CSVs. At this stage, you might do well to output all your text to the command line. Then you can see its format and demonstrate the creation of the lines is working.
To write simple text, you can use a file writer, but buffer it first, or you can use a Formatter. Go through the
Java Tutorials and you will find examples of both. You can wrap a File object in a Formatter and write like that. Remember you must close writers with a finally block (or try‑with‑resources); if you forget to close them, not only might the file be locked, but also you might fail to write anything. You will find links to different ways to close streams in
this post. That probably refers to readers, but you can doubtless change it to close your writer.
You want to move almost that code out of the main method; it is far too long already.