I am writing to a txt file and I am adding \ n (newline character). the symbol is clearly displayed in System.out.println. but this symbol does not appear in the text file. so the text file only consists of one long line
What operating system are you using? If you are using Windows try "\ r \ n" - or (more generally),System.getProperty("line.separator")
System.getProperty("line.separator")