I have a simple application that yet would trash a text file (it\'s just practice) I\'m only 3 days with Java yet. Problem is there are no errors until you run the program then
When you close the file as in the following line
file.close()
it means you are done working with the file.
In your case you close the file in the loop which means the next iteration will throw an exception.
Move the above mentioned code out of the loop.