Fixed error with small files

The plugin tried to access non-existing indexes for small files. By
checking the length of the list before reading, the issue has been
solved.