I am new to java and want to print the string present in the text file character by character but its only printing the first line string and when I write something on the next line in the text file the code is not printing them. Can someone help me in this. I am attaching the code below!
import java.io.File;
import java.util.Scanner;
import java.io.FileNotFoundException;
public class main {
    
    public static void main(String[] args) throws FileNotFoundException {
        char ch;
        
        File newFile = new File("C:/temp/sourcecode.txt");
        Scanner scanFile = new Scanner(newFile);
        
        String str;
        str = scanFile.nextLine();
        int l = str.length();
        for(int i =0; i<l ; i++) {
            ch = str.charAt(i);
            System.out.println(ch);
        }
    }
    
}
Thank you in advance!