Fixed code. It now compiles ones again. However somehow the calculation is broken.
made the code print out results to file