Those functions (fopen, fprintf, fclose) technically aren't async-signal-safe.
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_04

Also, sleep() returns when...