Why does this code print an extra line in the beginning, and also after accepting 2 strings it takes 0 to 2, which is 3 iterations to print the output?
import java.io.*;
import java.util.*;
public class Solution {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<=n;i++)
        {   String s1="",s2="";
            String str;
            str= sc.nextLine();
            int l=str.length();
            for (int k=0;k<l;k++)
            {
                if (k%2==0)
                    s1=s1+str.charAt(k); 
                else if(k%2!=0)
                    s2=s2+str.charAt(k);
            }
            System.out.println(s1+" "+s2);
        }
    }
}

 
     
    