adds read function to prob8.java