in reply to inplace file editing

UPDATE: btw, it prints only once if the file 'test' is empty but if it has any lines in it, it prints twice (which it shouldnt)