algorithm corrected. file reader corrected