added file writing and updated makefile