The sed does not support -i flag in the same way. The wc -l prints whitespace in front, which needs to be stripped.