Code cleanup by using Scala features like foreach and BufferedSource.