In Java, if you know for certain a file is very small, you can use
while read line
LINE = $line
done < "test.file"
Process the lines inside the loop instead of after it. If you really need the file in a variable: