@BarryCarlyon Thanks for your reply.
No I am not supposed to add the messages from scratch.
Instead I want to open the .txt file, want to decode json content from the file in which it will contain messages object or dictionary and i want to decode as array in php and then want to append it.
does this makes sense ?