Problems with Word Search program
<p>I am trying to create a word search program that puts words from a file into a matrix character by character.</p>

<pre><code>import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class SearchWord {
    public SearchWord() {

    }

    public void getMatrix() throws FileNotFoundException {
        File file = new File("C:/Users/Cameron/Desktop/words.txt");
        ArrayList&lt;Character&gt; words;

        String largest = " ";
        int col = 0;
        int count = 0;

        Scanner sc = new Scanner(file);
        Scanner newsc = new Scanner(file);

        while (sc.hasNextLine()) {
            String first = sc.next();
            String first1 = sc.nextLine();

            if (first.length() &gt; largest.length()) {
                largest = first;
                col = largest.length();
            }

            words = new ArrayList&lt;Character&gt;();

            for (int i = 0; i &lt; first.length(); i++) {
                words.add(first.charAt(i));
            }

            char[] chars = new char[words.size()];

            for (int i = 0; i &lt; chars.length; i++) {
                chars[i] = words.get(i);
            }

            char data[][] = new char[largest.length()][col];

            for (int i = 0; i &lt; chars.length; i++) {
                for (int j = 0; j &lt; largest.length(); j++) {
                    data[i][j] = chars[i];
                }
            }

            for (int i = 0; i &lt; data.length; i++) {
                for (int j = 0; j &lt; data[i].length; j++) {
                    System.out.println(data[i][j] + " ");
                }

                System.out.println();
            }
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        SearchWord check = new SearchWord();
        check.getMatrix();
    }
}
</code></pre>

<p>I have the words ladybug, fence, and hamburger in my words.txt file but I am having trouble reading them into the matrix correctly. I eventually want to have the words overlap on common letters. I also want the blank spaces to be filled with a random letter but I can get to that later.</p>

<p>It should look something like this:</p>

<pre><code>alaaaaafa
hamburger
adaaaaana 
ayaaaaaca
abaaaaaea 
auaaaaaaa
agaaaaaaa
</code></pre>

<p>But instead it does this:</p>

<pre><code>l l l l l l l 
a a a a a a a 
d d d d d d d 
y y y y y y y 
b b b b b b b 
u u u u u u u 
g g g g g g g 
h h h h h h h h h 
a a a a a a a a a 
m m m m m m m m m 
b b b b b b b b b 
u u u u u u u u u 
r r r r r r r r r 
g g g g g g g g g 
e e e e e e e e e 
r r r r r r r r r 
f f f f f f f f f 
e e e e e e e e e 
n n n n n n n n n 
c c c c c c c c c 
e e e e e e e e e 
</code></pre>