Fix IndexError raised by empty list at end of file
Merge pull request #1 from Rosuav/fixindexerror

Fix IndexError raised by empty list at end of file