Switch from scanner to bufferedreader to avoid running out of memory