# Use read mode instead of write and append mode open FILE, "<", "input.txt" or die $!; print "file loaded \n"; my @all_words; while () { # the words from *this* line my @words = split('', $_); # add to the complete word list push @all_words, @words; }