updated p1-p3 to redirect to output.txt