updated reverse to read and reverse input line by line