added fileWriter, added outputPath as parameter, removed compiler warnings, made few other changes