add file writting functionality