Find the total DOS shifted by the Fermi energy

def get_dos(self):
        '''Find the total DOS shifted by the Fermi energy'''
        # find the dos file
        fildos = ''
        for f in self._files:
            with open(f, 'r') as fp:
                first_line = next(fp)
                if "E (eV)" in first_line and "Int dos(E)" in first_line:
                    fildos = f
                    ndoscol = len(next(fp).split())-2 # number of spin channels
                    fp.close()
                    break
                fp.close()
        if not fildos:
            return None # cannot find DOS

        # get the Fermi energy
        line = self._get_line('the Fermi energy is', self.outputf)
        efermi = float(line.split('is')[-1].split()[0])

        # grab the DOS
        energy = [] ; dos = []
        fp = open(fildos, 'r')
        next(fp) # comment line
        for line in fp:
            ls = line.split()
            energy.append(Scalar(value=float(ls[0])-efermi))
            dos.append(Scalar(value=sum([float(i) for i in ls[1:1+ndoscol]])))
        return Property(scalars=dos, units='number of states per unit cell', conditions=Value(name='energy', scalars=energy, units='eV'))