I have search function once i have search String from clinet i want to loop through files and match the string from files in fs, I have problem in loop i want to get all match result and send result to client. Below trying to achieve but getting an error pasted in question. New to async library any help will be appreciated.

app.js

```
app.get('/serverSearch', function (req, res) {
    var searchTxt = req.query.searchTxt;
    dirDirectory.readDirectory(function(logFiles){
        // res.json(logFiles);
        if(logFiles){
            searchFileService.readFile(searchTxt,logFiles,function(lines,err){
                        console.log('Logs',lines);
                          if (err)
                           return res.send();
                           res.json(lines);
                    })

        }
    });

    console.log('Search text', searchTxt);
});

```

service.js

```
var fs = require('fs');
var path = require('path');
var async = require('async');
var searchStr;
var result = [];

//Async Method
function readFile(str, logFiles, callback) {
    async.series([
        //Load user to get `userId` first
        function(callback) {
            searchStr = str;
            for (var i = 0; i < logFiles.length; i++) {
                if (logFiles[i].filename !== '.gitignore') {
                    fs.readFile('logs/dit/' + logFiles[i].filename, 'utf8', function(err, data) {
                        if (err) {
                            return console.log(err);
                        }
                        inspectFile(data);
                    });
                }
                callback(result);
            }
        },
        //Load posts (won't be called before task 1's "task callback" has been called)
        function() {
            function inspectFile(data, callback) {
                var lines = data.split('\n'); // get the lines
                lines.forEach(function(line) { // for each line in lines
                    if (line.indexOf(searchStr) != -1) { // if the line contain the searchSt
                        result.push(line);
                        // then log it
                        return line;
                    }
                });
            }
        }
    ], function(err) { //This function gets called after the two tasks have called their "task callbacks"
        if (err) return err;
    });
};

```

Error

```
  if (fn === null) throw new Error("Callback was already called.");

```