Took multiple seconds to run, so I wonder if there's a more efficient way to do this. Maybe would be better to have a Vec<Vec<usize>> instead of putting all lines after each other.