and it printed the time..the reason for solution was it worked all the time without new line character program used to write all in tmp file and it started failing since this morning still not sure why this behaviour
Thanks again for all the replies which gave me an opportunity to try all sorts of things and worked well in the end