corrected 'readFromFile' function