use tmpnam function instead of hard coded tmpfile
fix unnecessary spaces and tabs