How to add new row immediately below the current row and not in the last.

How to add new row immediately below the current row and not in the last.

My current script is adding new row at the end of the subform but I want to add row next to or just below the current row. Can anyone help?

Current Script:
// Extract the numeric quantity from the 'Quantity added' string
addedQtyText = row.Quantity_Added.toString();
addedQtyNum = addedQtyText.replaceAll("[^0-9.]","");
// Remove all non-numeric characters, assuming a period for decimals
// Convert to number, with error handling for empty or invalid input
try 
{
addedQty = addedQtyNum.toDecimal();
}
catch (e)
{
addedQty = 0;
// Set a default or handle the error as appropriate
}
// Extract the numeric quantity from the 'Quantity to add' string
//toAddQtyText = input.Ingredients.Quantity_to_add.toString();
toAddQtyText = row.Quantity_to_add.toString();
toAddQtyNum = toAddQtyText.replaceAll("[^0-9.]","");
// Convert to number, with error handling
try 
{
toAddQty = toAddQtyNum.toDecimal();
}
catch (e)
{
toAddQty = 0;
// Set a default or handle the error as appropriate
}
// Validation for excess quantity
if(addedQty > toAddQty)
{
alert "Please check the quantity added, as it is more than required. कृपया जोड़ी गई मात्रा की जांच करें, क्योंकि यह आवश्यकता से अधिक है।";
return;
// Stop execution if the added quantity is too much
}
// Calculate the difference percentage
difference = toAddQty - addedQty;
percentageDiff = difference / toAddQty * 100;
// Check if the difference is greater than 0.5%
if(percentageDiff > 0.5)
{
// Add a new row with the same ingredient name and the difference as 'Quantity to add'
newSubformRow = Production_Batch.Ingredients();
newSubformRow.Ingredients=row.Ingredients;
newSubformRow.Quantity_to_add=difference.toString();
// Create a collection to hold the new row
rowsCollection = Collection();
rowsCollection.insert(newSubformRow);
// Use 'insert' to add the collection to the subform
input.Ingredients.insert(rowsCollection);
// Prompt for the remaining quantity
alert "Enter the remaining quantity in the next field and scan the new batch. अगले फील्ड में शेष मात्रा दर्ज करें और नए बैच को स्कैन करें।";
}