<commit_before>var fs = require('fs')
var http = require('http')

fs.readFile(process.argv[2], 'utf8', function(err, data) {
  if (err)
    throw err
  var url = data.replace(/^\s+|\s+$/g, '')

  var buff = []
  http.get(url, function(resp) {
    resp.on('data', function(chunk) {
      buff.push(chunk)
    }).on('error', function(err) {
      console.error(err)
      throw err
    }).on('end', function() {
      console.log(buff.join(''))
    })
  })
})<commit_msg>use async.waterfall as per official solution<commit_after>var fs = require('fs')
var http = require('http')
var async = require('async')

async.waterfall([
  function(callback) {
    fs.readFile(process.argv[2], 'utf8', function(err, data) {
      if (err)
        return callback(err)
      callback(null, data)
    })
  },

  function(data, callback) {
    var buff = []
    var url = data.replace(/^\s+|\s+$/g, '')
    http.get(url, function (resp) {
      resp.on('data', function (chunk) {
        buff.push(chunk)
      }).on('error', function (err) {
        callback(err)
      }).on('end', function() {
        console.log(buff.join(''))
      })
    }).on('error', function (err) {
      callback(err)
    })
  }],

  function (err, result) {
    if (err)
      console.error(err)
    else
      console.log(result)
  }

)
{'fraction_non_alphanumeric': 0.19446579554189086, 'fraction_numerical': 0.0030745580322828594, 'mean_word_length': 2.667605633802817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5144198', 'n_tokens_mistral': 454, 'n_tokens_neox': 448, 'n_words': 91}