fix: writefile
add: some function definitions.