Now restores the cursor to the last position after write

The cursor previously went the last edited line due to the write function search and replace