First, did you take a stab at it? What results did you get? It looks like you are just trying to edit a text file. Have you tried the native kix readline or readprofilestring (and corresponding writes)?