splitting a string on a new line into seperate variable : so i have a variable id that outputs 
`
1
2
3
4
5
`
i just want to grab the first number 1 and add that as student1.id
and the second number as student2.id and so on. 

currently if i print student1.id i get
`
1
2
3
4
5
`

how would i go about this? i tried doing a for loop but it said it is not iteratable. 

    public class main {	
    	/**
    	* Reads a text file containing student data and uses this to populate the student objects
    	*
    	* @param filename Path to the student data file to be read
    	* @return Whether the file was read successfully
    	*/
    	public static boolean readFile(String filename) { File file = new File(filename);
    	try {
    	Scanner scanner = new Scanner(file);
    	while(scanner.hasNextLine()){
    	String[] words = scanner.nextLine().split(",");
    	addStudent(words[0],words[1],words[2],words[3],words[4],words[5],words[6],words[7],words[8]); // TODO: Finish adding the parameters
    	}
    	scanner.close();
    	} catch (FileNotFoundException e) { System.out.println("Failed to read file");
    	}
    	return true;
    	}
	
	static void addStudent(String id, String firstName, String lastName, String mathsMark1, String mathsMark2, String mathsMark3, String englishMark1, String englishMark2, String englishMark3) {
		
		Student student1 = new Student();
		Student student2 = new Student();
		Student student3 = new Student();
		Student student4 = new Student();
		Student student5 = new Student();
		
		student1.id = id;
		student1.firstname = firstName;
		student1.lastname = lastName;

		
		  System.out.println(student1.id);
		
		
		
	}