reader.readLine() not working as expected

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class CSS_Test_4_10_2024 {
    public static void main(String args[]) {
        try (BufferedReader reader = new BufferedReader(new FileReader("...\\sentences.txt"))) {
            String sentence;
            int c = 0; int inc = -5;
            while ((sentence = reader.readLine()) != null) {
                
                for (int i = 5; i > 0; i--) {
                    for (int o = 1; o < 4; o++) {
                        c++;
                        inc += i;
                        System.out.printf("<div class=\"text\" style=\"top: %dex;\">%s %d</div>%n", inc, sentence, c);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

I have a sentences.txt with 60 lines of text.
I wanted it to print something along the lines of:
<div class="text" style="top: [THIS STARTS FROM 5 AND INCREMENTS BY 5, AND FOR EACH THREE INCREMENTS, THE INCREMENT DECREASES BY 1]ex;">[SENTENCE GOES HERE] [HOW MANY TIMES THIS HAS RUN GOES HERE]</div>
As an example, the first few lines should show:
<div class="text" style="top: 5ex;"> Lorem ipsum... 1</div>
<div class="text" style="top: 10ex;"> dolor sit amet... 2</div>
<div class="text" style="top: 15ex;"> adipscicing ameold.. 3</div>
<div class="text" style="top: 19ex;"> molor alor... 4</div>
...
<div class="text" style="top: ??ex;"> blablabla... ?<60</div>

To my confusion, the result looks like:
...
<div class="text" style="top: 2694ex;">Curabitur rutrum... 899</div>
<div class="text" style="top: 2695ex;">Curabitur rutrum... 900</div>
Not only did reader.readLine() seem to read the same line (not shown, but it does this every 16~ times), and the top:??ex and number at the end seems to vastly exceed what I thought should have resulted from the for loop
Was this page helpful?