Q:

How to fix name sorter? NoSuchElementFound error...?

I wrote name sorting program designed to sort a list of names (duh) and give index value of my name. For some reason it compiles fine but says there's something wrong with 'maleNames[i] = nameScan.nextLine();" and returns this message:
java.util.NoSuchElementException: No line found
    at java.util.Scanner.nextLine(Scanner.java:1540)
    at NameSorter.main(NameSorter.java:14)

Any ideas or fixes? Thanks in advance!
import java.io.*;
import java.util.Scanner;
public class NameSorter
{
    public static void main(String [] args) throws FileNotFoundException
    {
        String [] maleNames = new String[1220];
        PrintStream ps = new PrintStream("sorted_male_names.txt");

        Scanner nameScan = new Scanner(new File("common_male_names.txt"));

        for (int i = 0; i < maleNames.length; i++)
        {
            maleNames[i] = nameScan.nextLine();
        }

        bubbleSort(maleNames);

        for (int i = 0; i < maleNames.length; i++)
        {
            System.out.println(maleNames[i]);
        }

        for (int i = 0; i < maleNames.length; i++)
        {
            String currentName = maleNames[i];
            ps.println(currentName);
        }

        System.out.println(linearSearch(maleNames, "zander"));
    }

    public static boolean isSorted(String[] arr)
    {
        for (int i = 0; i < arr.length -1; i++)
        {
            if (arr[i].compareTo(arr[i+1]) > 0)
                return false;
            }
        return true;
    }

    public static void swapElements(String[] arr, int index1, int index2)
    {
        String tempValue = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = tempValue;
    }

    public static void bubbleSort(String[] arr)
    {
        while(isSorted(arr) == false) // while(!isSorted(arr)) 
        {
        for (int i = 0; i < arr.length - 1; i++)
        {
            if (arr[i].compareTo(arr[i+1]) > 0)
            swapElements(arr, i, i+1);
        }
        }
    }

    public static int linearSearch(String[] arr, String name)
    {
        for (int i = 0; i > arr.length; i++)
        {
            if (arr[i].equals(name))
            return i;
        }
        return -1;
    }

    public static void printArray(int[] arr)
    {
        for (int i = 0; i < arr.length; i++)
        {
            System.out.print(arr[i] + " ");
        }
    }
}

A:

Your for loop
for (int i = 0; i < maleNames.length; i++) {
        maleNames[i] = nameScan.nextLine();
}

Assumes there are maleNames.length elements in the file (1220 in this case) if there are fewer than that you will get a NoSuchElementException
A better way would be to use the Scanner's hasNextLine() method and a List<String> 
List<String> maleNames = new ArrayList<>();

while(nameScan.hasNextLine()) { 
    maleNames.add(nameScan.nextLine());
}

This would allow for a name file of any length, so long as its correctly formatted, and avoids your exception. 

