My code has to read 50 lines of input and output them in reverse order, then other 50 lines, so output starts from 50th line, goes to the 1st one, then it start from 100th line to 50th I got it to work. But the only thing, that 51 line isn't printed, I can't get what's going wrong. 

```
public static void doIt(BufferedReader r, PrintWriter w) throws IOException {
    String newString;
    LinkedList<String> list = new LinkedList<String>();
    int i = 0;
    while ((newString = r.readLine()) != null) {
        if (i < 50) {
            i++;
            list.addFirst(newString);
        } else {
            for (String s : list)
                w.println(s);
            list.clear();
            i = 0;
        }
    }

    for (String s : list)
        w.println(s);

}

```