Changed the list of line indexes to be one-based and made it more robust
for wrong inputs