A common error is to open() a file for writing before calling flock(). In that case, the file's contents are wiped by the open() before flock() checks if it's locked or not, by which time it's too late.
Of course, it's impossible to tell what your problem is without seeing any code.
Yes. That is exactly what I do (and that's what I've learned from books) - that a file must first be opened and then flock can be called. If this is not the proper way of using flock, what is?