Write file in background