" public class Solution { public static void main(String[] args) throws FileNotFoundException,IOException { BufferedReader bufferedReader1 = new BufferedReader(new InputStreamReader(System.in)); BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(System.in)); /* File file1 = new File("C:/a/result.txt"); File file2 = new File("C:/a/resultOut1.txt"); */ File file1 = new File(bufferedReader1.readLine()); File file2 = new File(bufferedReader2.readLine()); FileInputStream fileInputStreamIn = new FileInputStream(file1); byte[] input = new byte[fileInputStreamIn.available()]; fileInputStreamIn.read(input); fileInputStreamIn.close(); //reverse process //System.out.println(input.length); byte[] reversedOutput = new byte[input.length]; int counterForreversedOutput = 0; for (int i=input.length-1;i>=0;i--){ //System.out.println(i); reversedOutput[counterForreversedOutput]=input[i]; counterForreversedOutput++; } for(byte b : input) System.out.println(b); for(byte b : reversedOutput) System.out.println(b); System.out.println(reversedOutput.length); FileOutputStream fileOutputStream = new FileOutputStream(file2); fileOutputStream.write(reversedOutput,0,reversedOutput.length); fileOutputStream.close(); } } " Hi I would like to ask why I have empty lines in the produced file; original file: ' a b c d a e f ' produced file: ' f e a d c b a '