I am trying to make the javascript read txt file which is working, and I want it to add each row in the txt file in a Column in the table and after 3 Columns start a new row in the table and so on. also while the javascript reading my txt and once it sees \n it moves to the next row in text file and add it to a column in the table. Then display it in the div

Here is what I have

test.html

HTML Code:
    <script>
    if (window.XMLHttpRequest) {
    //for firefox, opera and safari browswers
    var txtFile = new XMLHttpRequest();
    }
    if (typeof XMLHttpRequest == "undefined")
    XMLHttpRequest = function () {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
    catch (e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
    catch (e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {}
    throw new Error("This browser does not support XMLHttpRequest.");
    };
    txtFile.open("GET","text.txt");
    txtFile.send(false);
    // var allText = txtFile.responseText;
    function clickyHere(){
    var info = txtFile.responseText;
    var infoArray = [];
    infoArray = info.split(/,|,+\s|\s+,\n|\r/);
    var tableCount = info.split(/,|\$/g).length;
    var rowCount = info.split(/\r|[\r]/g).length;
    var endLine = info.split(/\$/g).length;
    var newLine = info.replace(/\r\n/g,'\n').length;
    var columnTry = tableCount/endLine;
    document.write("<table border='1' columns='"+columnTry+"'>");
    var count;
    count = 0;
    for (i=0;i<infoArray.length;i++){
    x = infoArray[i];
    document.write("<td>"+x+" ");
    if (count != columnTry){
    count ++;
    }
    if (count >= columnTry){
    document.write("</tr><tr>");
    count = 0;
    }
    }
    document.write("</tr></table>");
    }
    </script>
    <div id="test" onload="clickyHere"></div>
text.txt

HTML Code:
    1, 1, aaa \n
    2, 2, aaa \n
    3, 3, aaa \n
    4, 4, aaa \n
    5, 5, aaa \n
    6, 6, aaa \n
    7, 7, aaa \n