added file writing