Examples of reading and writing files
Factor handbook > Input and output > Reading and writing files

Next:<file-reader> ( path encoding -- stream )

Sort the lines in a file and write them back to the same file:
USING: io io.encodings.utf8 io.files sequences sorting ; "lines.txt" utf8 [ file-lines natural-sort ] 2keep set-file-lines

Read 1024 bytes from a file:
USING: io io.encodings.binary io.files ; "data.bin" binary [ 1024 read ] with-file-reader