Add return statement if writing fail.

Signed-off-by: Antti-Ville Jokela <antti-ville@avjokela.eu>