Added finally block to getProfiles to close reader