Gil - That's just because you're performing the following action every time the loop runs through a cycle:
PHP Code:
print($strLine[$line]."<br />\n");
The print statement you have after setting the $sql variable each time is plenty.
In order to avoid the first empty statement, I would recommend changing this statement:
PHP Code:
if($k % 9 == 0){
to
PHP Code:
if($k % 9 == 0 && !empty($k)){