My Text file Contains line like this
FLTR TID: 0000003756 RPC ID: 0000108159 USER: Remedy Application Service
FLTR TID: 0000003756 RPC ID: 0
I would suggest you two improvements which will make it easier to solve your issue.
1) Do not attempt to write into Excel sheet using Java, its slightly complicated. Instead you can write into a CSV file. You can externally open this CSV file and save as Excel.
2) The below line might cause trimming of the user names:
user=str.substring(48,75); // This is to get user names
Instead you can use
user=str.substring(48); // This is to get user names
So, writing a CSV doesn't need Excel libraries and it can be opened in an excel workbook as well. :)