Fix unexpected end of input errors when reading list