Hello and welcome to the forum,
and what does
MOVE 20 TO LIN.
MOVE 30 TO COL.
This is "your" code - why did you write this?
One of the pitfalls of grabbing code from just anywhere is that while it may appear to work, it may not work for all cases or it may contain some surprises. Another is that you try to implement something you do not yet understand. The reason your class is given these exercises is for you to learn.
We have several "seniors" here who will help you thru writing/debugging your code, but the biggest amount of effort should be for you.