You could avoid this string truncation by adding the "[\n" in the else instead. This would be cleaner IMO.