Fixed the sorting and blank lines removal functions.