fixed readLines implementation