added file writing code - basic for now