Solution using input output files