porting to fileoutput; redirect to output file for now; redundant clauses and not working