problem solved: i had to call flush() on the file before accessing it. no idea though, why it only occured when creating a temporary file.