Fixing issue with empty lines list causing unexpected errors. TODO: check if lines are empty in a safe way