use FileSystem API to write file