document.getElementById('inputfile') .addEventListener('change', function() { var fr = new FileReader(); fr.onload = function() { if (!fr.result) { // if empty result do not execute below code return; } const resultAsArray = fr.result.split('\r\n'); // split the text into array by new line (\r\n) let index = 0; // Take the first line const displayInterval = setInterval(() => { // create an interval that executes every 1 second if (index === (resultAsArray.length - 1)) { // check if the current index is equal to last item index clearInterval(displayInterval); // if true, exit the interval r