From one text file to the second, you need to rewrite all the lines, inserting its length at the end of each line. Here is the listing
public static void main(String[] args) { try(FileWriter writer = new FileWriter("C:\\prg1\\Letter.txt", false)){ BufferedReader reader = new BufferedReader(new FileReader("C:\\prg1\\test2.txt")); String tmp; while( (tmp = reader.readLine())!= null ){ writer.write(tmp); writer.write(tmp.length()); writer.append( '\n');// делал также writer.write( '\n'); } writer.close(); reader.close(); catch(IOException ex){ System.out.println(ex.getMessage()); } } The problem is that in the resulting file "Letter.txt" transitions to a new line are missing, that is, writer.append ('\ n') or writer.write ('\ n') does not work.