I believe you can not TRIM last line of file until and unless you fetch file into memory. You can read a part of file and write into file(this will either truncate file first or append the file) but there is no option for REPLACE in file without bringing it into memory. you need to read all lines, and make changes and then write it back.
How you pass the file to SQL. You pass it from vb.net OR read it from SQL directly ??
So, it may possible that I could help you on that.
-Shahan