Fixed bugs in `stat` and `readdir`

Sorry if this is not correct, but I was getting `undefined` errors when doing stat and list commands.

It seems that the respective for/loops where iterating from 0 to list.length, when they should be iterating from 0 to (list.length - 1) to account for zero indexing.