MY goal is to compare two files line by line and capture the changes. For that i am using two nested loops. I am stuck with braking the inner loop on some condition.
you do not have to reinvent the wheel (if you have a choice). This is just one way. Download diffutils for windows and then you can just do
diff sample.txt test.txt