I am having a couple problems getting my code below to work properly. Firstly, is it wants to print "1>" twice before moving on to "2>". Meaning I have two hit enter an extra time before it moves on to "2>" Secondly, when I input L to print the current list it is leaving out printing the first couple of lines. It should print whatever is above it whether line is blank or has text. Below is my code, the output I am getting, and what the output should look like. Here is my code for a line/file editor: import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class FileEdit { public static List lines = new ArrayList(); public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); System.out.print("EDIT: "); String fileName = s.nextLine(); BufferedReader br = new BufferedReader(new FileReader(new File(fileName))); String str=""; int count=0; while((str=br.readLine())!=null) { lines.add(count, str); System.out.println((++count) + "> "+ str); } String text=""; String command = ""; System.out.print((++count)+"> "); command=s.nextLine(); String commandArr[]; int flag; while(!command.equals("E")) { flag=0; commandArr = command.split("\\s"); if(commandArr[0].equals("I")) //Insertion { while(true) { if(commandArr.length==1&&flag!=2) { System.out.print((count)+"> "); text = s.nextLine(); insertLine(text,count-1); } else if(commandArr.length==2&&flag!=2) { System.out.print((commandArr[1])+"> "); count=Integer.parseInt(commandArr[1]); text = s.nextLine(); insertLine(text,Integer.parseInt(commandArr[1])-1); } else insertLine(text,count-1); System.out.print((++count)+"> "); command=s.nextLine(); commandArr = command.split("\\s"); if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm andArr[0].equals("E")) { flag=1; break; } else { flag=2; text=command; } } } else if(commandArr[0].equals("L")) //Listing { printList(); } else if(commandArr[0].equals("D")) //Deletion { if(commandArr.length==1) { deleteLine(count-1,count-1); } else if(commandArr.length==2) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1); } else if(commandArr.length==3) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1); } count=lines.size(); } if(flag!=1) { System.out.print((count++)+"> "); command = s.nextLine(); } } } public static void insertLine(String text,int count) { if (count >= lines.size()) { for(int i = lines.size(); i <= count; i++) { lines.add(null); } } lines.set(count,text); } public static void deleteLine(int start,int end) { for(int i=start;i<=end;i++) lines.remove(i); } public static void printList() { for(int i=0;i "+lines.get(i)); } } Here is the output I keep getting where when I hit print it prints "1>" then when I hit it a second time it prints "1>" again, when it needs to move on to "2>" EDIT: textin.txt 1> Th.